Skip to content

Commit

Permalink
Lower case toggle name to simplify future toggles
Browse files Browse the repository at this point in the history
Should probably also register toggle commands programmatically
  • Loading branch information
Jikoo committed Jul 27, 2024
1 parent 31619d2 commit 68f0b7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public final class Toggles {

private static final Map<String, PlayerToggle> TOGGLES = new HashMap<>();
private static final PlayerToggle ANY = add(new MemoryToggle("AnyContainer"));
private static final PlayerToggle SILENT = add(new MemoryToggle("SilentContainer"));
private static final PlayerToggle ANY = add(new MemoryToggle("anycontainer"));
private static final PlayerToggle SILENT = add(new MemoryToggle("silentcontainer"));

public static @NotNull PlayerToggle any() {
return ANY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
Expand All @@ -48,8 +49,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
}

boolean any = command.getName().startsWith("any");
PlayerToggle toggle = any ? Toggles.any() : Toggles.silent();
PlayerToggle toggle = Toggles.get(command.getName());

// Shouldn't be possible.
if (toggle == null) {
JavaPlugin.getProvidingPlugin(getClass()).getLogger().warning("Command /" + command.getName() + " registered with no corresponding toggle!");
return false;
}

UUID playerId = player.getUniqueId();

if (args.length > 0) {
Expand Down

0 comments on commit 68f0b7b

Please sign in to comment.