updated javadoc for experience tracking

added/changed some javadoc for mod mail
some small interface changes
changed a few methods to actually use the exists mechanic, instead of checking for null values
added some templates instead of hard coded strings
fixed some bugs related to mod mail
This commit is contained in:
Sheldan
2020-06-13 00:51:50 +02:00
parent e76351ddc1
commit 19a7d09576
111 changed files with 1238 additions and 162 deletions

View File

@@ -3,6 +3,9 @@ package dev.sheldan.abstracto.experience.config.features;
import dev.sheldan.abstracto.core.config.FeatureEnum;
import lombok.Getter;
/**
* The experience tracking feature enum, this is used to switch off/on experience tracking.
*/
@Getter
public enum ExperienceFeature implements FeatureEnum {
EXPERIENCE("experience");

View File

@@ -7,11 +7,24 @@ import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* {@link FeatureConfig} instance containing the required configuration concerning system config and post targets for
* the {@link ExperienceFeature} feature.
*/
@Component
public class ExperienceFeatureConfig implements FeatureConfig {
/**
* Minimum experience a user can earn per tracked message
*/
public static final String MIN_EXP_KEY = "minExp";
/**
* Maximum experience a user can earn per tracked message
*/
public static final String MAX_EXP_KEY = "maxExp";
/**
* The multiplier which is applied to each calculated gained experience
*/
public static final String EXP_MULTIPLIER_KEY = "expMultiplier";
@Override
@@ -19,6 +32,9 @@ public class ExperienceFeatureConfig implements FeatureConfig {
return ExperienceFeature.EXPERIENCE;
}
/**
* All of the configuration keys are required in order for this feature to function
*/
@Override
public List<String> getRequiredSystemConfigKeys() {
return Arrays.asList(EXP_MULTIPLIER_KEY, MIN_EXP_KEY, MAX_EXP_KEY);

View File

@@ -6,6 +6,9 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
/**
* A role for which the experience gain in a particular server has been disabled.
*/
@Builder
@Entity
@NoArgsConstructor

View File

@@ -10,6 +10,9 @@ import lombok.experimental.SuperBuilder;
import java.util.ArrayList;
import java.util.List;
/**
* Model used to render an overview of the roles for which experience gain has been disabled on the current server.
*/
@Getter
@Setter
@SuperBuilder

View File

@@ -7,7 +7,7 @@ import lombok.Setter;
import net.dv8tion.jda.api.entities.Member;
/**
* Model used in the list of members when rendering the leaderboard command. The reason this is necessary,
* Model used in the list of members when rendering the leaderboard template. The reason this is necessary,
* is because we need more than just the {@link AUserExperience} object, we also need the position of the user in this
* guild and the {@link Member} for convenience in the templates.
*/

View File

@@ -6,7 +6,7 @@ import lombok.Setter;
/**
* Object containing the status update information when the user executes the
* command responsible for synchronizing the users with their experience roles. This is a very barebones
* command responsible for synchronizing the users with their experience roles. This is a very small
* object as it only contains the current count and the total amount.
*/
@Getter

View File

@@ -44,7 +44,7 @@ public interface AUserExperienceService {
AExperienceLevel calculateLevel(AUserExperience experience, List<AExperienceLevel> levels);
/**
* Increases the experience of the provided {@link AUserExperience} object and and calculates the new level according
* Calculates the new level of the provided {@link AUserExperience} according
* to the provided list of {@link AExperienceLevel} used as level configuration
* @param userExperience The {@link AUserExperience} to increase the experience for
* @param levels The list of {@link AExperienceLevel} to be used as level configuration
@@ -127,6 +127,15 @@ public interface AUserExperienceService {
*/
void executeActionOnUserExperiencesWithFeedBack(List<AUserExperience> experiences, AChannel channel, Consumer<AUserExperience> toExecute);
/**
* Disables the experience gain for a user directly. This sets the `experienceGainDisabled` on the respective {@link AUserExperience} object to true
* @param userInAServer The {@link AUserInAServer} to disable experience gain for
*/
void disableExperienceForUser(AUserInAServer userInAServer);
/**
* Enables the experience gain for a user directly. This sets the `experienceGainDisabled` on the respective {@link AUserExperience} object to false
* @param userInAServer The {@link AUserInAServer} to enable experience for
*/
void enableExperienceForUser(AUserInAServer userInAServer);
}

View File

@@ -36,5 +36,13 @@ public interface ExperienceRoleService {
*/
AExperienceRole calculateRole(AUserExperience userExperience, List<AExperienceRole> roles);
/**
* Calculates the level at which the next role for a given level is available.
* For example, if the given {@link AExperienceLevel} is 5, and a a {@link AExperienceRole} is awarded at 8, but none in between, this method will return
* the {@link AExperienceLevel} 8.
* @param startLevel The {@link AExperienceLevel} to start off at
* @param server The {@link AServer} to use for the {@link AExperienceRole} configuration
* @return The next {@link AExperienceLevel} a {@link AExperienceRole} is awarded at, this will be null if there are no roles or there is no further role to reach
*/
AExperienceLevel getLevelOfNextRole(AExperienceLevel startLevel, AServer server);
}

View File

@@ -6,9 +6,37 @@ import dev.sheldan.abstracto.experience.models.database.ADisabledExpRole;
import java.util.List;
/**
* Service used to manage the instances of {@link ADisabledExpRole} in the database, which includes creating, removing and retrieving them
*/
public interface DisabledExpRoleManagementService {
/**
* Creates an instance of {@link ADisabledExpRole} which marks the {@link ARole} as disabled. This effectively means, that the experience is disabled for members
* which have the {@link ARole}
* @param role The {@link ARole} which should be used as a role to disable experience
* @return The create instance of {@link ADisabledExpRole}
*/
ADisabledExpRole setRoleToBeDisabledForExp(ARole role);
/**
* Removes the given {@link ARole} from the list of roles which had their experience gain disabled. This method removes the instance from the list of
* {@link ADisabledExpRole} and enables experience for the given {@link ARole}
* @param role The {@link ARole} to enable experience for
*/
void removeRoleToBeDisabledForExp(ARole role);
/**
* Retrieves all the {@link ADisabledExpRole} roles for a given {@link AServer}, which means, it returns all roles for which there is
* @param server The {@link AServer} to retrieve all {@link ADisabledExpRole} for
* @return A List of {@link ADisabledExpRole} which are currently on the {@link AServer}
*/
List<ADisabledExpRole> getDisabledRolesForServer(AServer server);
/**
* Checks if the given {@link ARole} has its experience disabled and returns true if so
* @param role The {@link ARole} to check for
* @return Whether or not the given {@link ARole} has the experience disabled.
*/
boolean isExperienceDisabledForRole(ARole role);
}

View File

@@ -51,7 +51,7 @@ public interface UserExperienceManagementService {
* @param end The end index for which to return a sublist of {@link AUserExperience} elements for
* @return A list desc ordered by {@link AUserExperience.experience} only containing the elements between {@code start} and @{code end}
*/
List<AUserExperience> findLeaderboardUsersPaginated(AServer server, Integer start, Integer end);
List<AUserExperience> findLeaderBoardUsersPaginated(AServer server, Integer start, Integer end);
/**
* Returns the {@link LeaderBoardEntryResult} of the given {@link AUserExperience}.