Skip to content

Commit

Permalink
don't register vote/votestreak if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kikelkik committed Mar 28, 2023
1 parent 2866b50 commit c7b07e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.minimum.minecraft</groupId>
<artifactId>SuperbVote</artifactId>
<version>0.5.5</version>
<version>0.5.6-CORP-2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/io/minimum/minecraft/superbvote/SuperbVote.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public void onEnable() {
}

getCommand("superbvote").setExecutor(new SuperbVoteCommand());
getCommand("vote").setExecutor(configuration.getVoteCommand());
getCommand("votestreak").setExecutor(configuration.getVoteStreakCommand());
registerCommands();

getServer().getPluginManager().registerEvents(new SuperbVoteListener(), this);
getServer().getPluginManager().registerEvents(new TopPlayerSignListener(), this);
Expand Down Expand Up @@ -124,8 +123,7 @@ public void reloadPlugin() {
scoreboardHandler.reload();
voteServiceCooldown = new VoteServiceCooldown(getConfig().getInt("votes.cooldown-per-service", 3600));
getServer().getScheduler().runTaskAsynchronously(this, getScoreboardHandler()::doPopulate);
getCommand("vote").setExecutor(configuration.getVoteCommand());
getCommand("votestreak").setExecutor(configuration.getVoteStreakCommand());
registerCommands();

if (voteReminderTask != null) {
voteReminderTask.cancel();
Expand All @@ -141,4 +139,13 @@ public void reloadPlugin() {
public ClassLoader _exposeClassLoader() {
return getClassLoader();
}

private void registerCommands() {
if (configuration.getVoteCommand() != null) {
getCommand("vote").setExecutor(configuration.getVoteCommand());
}
if (configuration.getVoteStreakCommand() != null) {
getCommand("votestreak").setExecutor(configuration.getVoteStreakCommand());
}
}
}
5 changes: 0 additions & 5 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ commands:
superbvote:
description: SuperbVote main command.
aliases: [sv]
vote:
description: SuperbVote vote command.
votestreak:
description: SuperbVote vote streak command.
aliases: [vstreak]
permissions:
superbvote.notify:
default: true
Expand Down

0 comments on commit c7b07e3

Please sign in to comment.