Skip to content

Commit

Permalink
[AB-xxx] adding/updating documentation for core and experience module
Browse files Browse the repository at this point in the history
updating asciidoctor plugin version
adding check to not allow duplicate level action configurations
limiting experience level up notification toggle command to be only available if the feature mode is enabled
  • Loading branch information
Sheldan committed Apr 18, 2024
1 parent dfe9792 commit 43c5d04
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import dev.sheldan.abstracto.experience.config.ExperienceFeatureDefinition;
import dev.sheldan.abstracto.experience.config.ExperienceFeatureMode;
import dev.sheldan.abstracto.experience.config.ExperienceSlashCommandNames;
import dev.sheldan.abstracto.experience.exception.LevelActionAlreadyExistsException;
import dev.sheldan.abstracto.experience.exception.LevelActionNotFoundException;
import dev.sheldan.abstracto.experience.listener.LevelActionListener;
import dev.sheldan.abstracto.experience.model.LevelActionPayload;
Expand Down Expand Up @@ -99,6 +100,9 @@ public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEven
return userExperienceManagementService.saveUser(user);
});
}
if(levelActionManagementService.getLevelAction(actionName, level, server, userExperience).isPresent()) {
throw new LevelActionAlreadyExistsException();
}
levelActionManagementService.createLevelAction(level, server, actionName, userExperience, payload);
return interactionService.replyEmbed(RESPONSE_TEMPLATE, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.FeatureMode;
import dev.sheldan.abstracto.core.interaction.InteractionService;
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import dev.sheldan.abstracto.experience.config.ExperienceFeatureDefinition;
import dev.sheldan.abstracto.experience.config.ExperienceFeatureMode;
import dev.sheldan.abstracto.experience.config.ExperienceSlashCommandNames;
import dev.sheldan.abstracto.experience.service.AUserExperienceService;
import net.dv8tion.jda.api.entities.Member;
Expand Down Expand Up @@ -100,4 +102,10 @@ public CommandConfiguration getConfiguration() {
.help(helpInfo)
.build();
}


@Override
public List<FeatureMode> getFeatureModeLimitations() {
return Arrays.asList(ExperienceFeatureMode.LEVEL_UP_NOTIFICATION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.sheldan.abstracto.experience.exception;

import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.templating.Templatable;

public class LevelActionAlreadyExistsException extends AbstractoRunTimeException implements Templatable {

public LevelActionAlreadyExistsException() {
super("Level action already exists.");
}

@Override
public String getTemplateName() {
return "level_action_already_exists_exception";
}

@Override
public Object getTemplateModel() {
return new Object();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEven
} else if(slashCommandParameterService.hasCommandOptionWithFullType(USER_PARAMETER, event, OptionType.STRING)){
String userIdStr = slashCommandParameterService.getCommandOption(USER_PARAMETER, event, User.class, String.class);
Long userId = Long.parseLong(userIdStr);
AUserInAServer userInServer = userInServerManagementService.createUserInServer(event.getGuild().getIdLong(), userId);
AUserInAServer userInServer = userInServerManagementService.loadOrCreateUser(event.getGuild().getIdLong(), userId);
infractions = infractionManagementService.getInfractionsForUser(userInServer);

} else {
Expand Down
6 changes: 5 additions & 1 deletion abstracto-application/documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@
<configuration>
<outputFile>index.html</outputFile>
<sourceDirectory>src/main/docs/asciidoc</sourceDirectory>
<backend>html</backend>
<backend>html5</backend>
<doctype>book</doctype>
<attributes>
<toc>left</toc>
<icons>font</icons>
</attributes>
</configuration>
</execution>
</executions>
Expand Down
Loading

0 comments on commit 43c5d04

Please sign in to comment.