Skip to content

Commit

Permalink
Unregister commands only if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ruViolence committed Jan 14, 2024
1 parent 3680030 commit 3b373e6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/net/elytrium/velocitytools/VelocityTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,27 @@ public void reload() {
}

List<String> aliases = Settings.IMP.COMMANDS.HUB.ALIASES;
aliases.forEach(alias -> this.server.getCommandManager().unregister(alias));
if (Settings.IMP.COMMANDS.HUB.ENABLED && !aliases.isEmpty()) {
aliases.forEach(alias -> this.server.getCommandManager().unregister(alias));
this.server.getCommandManager().register(aliases.get(0), new HubCommand(this.server), aliases.toArray(new String[0]));
}

this.server.getCommandManager().unregister("alert");
this.server.getCommandManager().unregister("find");
this.server.getCommandManager().unregister("send");
this.server.getCommandManager().unregister("velocitytools");

if (Settings.IMP.COMMANDS.ALERT.ENABLED) {
this.server.getCommandManager().unregister("alert");
this.server.getCommandManager().register("alert", new AlertCommand(this.server));
}

if (Settings.IMP.COMMANDS.FIND.ENABLED) {
this.server.getCommandManager().unregister("find");
this.server.getCommandManager().register("find", new FindCommand(this.server));
}

if (Settings.IMP.COMMANDS.SEND.ENABLED) {
this.server.getCommandManager().unregister("send");
this.server.getCommandManager().register("send", new SendCommand(this.server));
}

this.server.getCommandManager().unregister("velocitytools");
this.server.getCommandManager().register("velocitytools", new VelocityToolsCommand(this), "vtools");

this.server.getEventManager().unregisterListeners(this);
Expand Down

0 comments on commit 3b373e6

Please sign in to comment.