diff --git a/api/src/main/java/com/lishid/openinv/util/setting/PlayerToggles.java b/api/src/main/java/com/lishid/openinv/util/setting/PlayerToggles.java index 5a53b998..d61cd115 100644 --- a/api/src/main/java/com/lishid/openinv/util/setting/PlayerToggles.java +++ b/api/src/main/java/com/lishid/openinv/util/setting/PlayerToggles.java @@ -8,6 +8,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -18,8 +19,8 @@ public final class PlayerToggles { private static final Map 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")); /** * Get the AnyContainer toggle. @@ -46,7 +47,11 @@ public final class PlayerToggles { * @return the toggle, or null if no such toggle exists. */ public static @Nullable PlayerToggle get(@NotNull String toggleName) { - return TOGGLES.get(toggleName); + PlayerToggle toggle = TOGGLES.get(toggleName); + if (toggle == null) { + toggle = TOGGLES.get(toggleName.toLowerCase(Locale.ENGLISH)); + } + return toggle; } /** @@ -59,7 +64,7 @@ public final class PlayerToggles { } private static @NotNull PlayerToggle add(@NotNull PlayerToggle toggle) { - TOGGLES.put(toggle.getName(), toggle); + TOGGLES.put(toggle.getName().toLowerCase(Locale.ENGLISH), toggle); return toggle; } diff --git a/plugin/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/src/main/java/com/lishid/openinv/OpenInv.java index 3a6cfea6..3f74b3ec 100644 --- a/plugin/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/src/main/java/com/lishid/openinv/OpenInv.java @@ -52,6 +52,7 @@ import org.jetbrains.annotations.Nullable; import java.nio.file.Path; +import java.util.Locale; import java.util.UUID; import java.util.function.Consumer; @@ -158,7 +159,7 @@ private void registerCommands() { ContainerSettingCommand settingCommand = new ContainerSettingCommand(languageManager); for (PlayerToggle toggle : PlayerToggles.get()) { - setCommandExecutor(settingCommand, toggle.getName()); + setCommandExecutor(settingCommand, toggle.getName().toLowerCase(Locale.ENGLISH)); } } diff --git a/plugin/src/main/java/com/lishid/openinv/listener/ToggleListener.java b/plugin/src/main/java/com/lishid/openinv/listener/ToggleListener.java index 2714acdc..b39535ae 100644 --- a/plugin/src/main/java/com/lishid/openinv/listener/ToggleListener.java +++ b/plugin/src/main/java/com/lishid/openinv/listener/ToggleListener.java @@ -1,5 +1,6 @@ package com.lishid.openinv.listener; +import com.google.errorprone.annotations.Keep; import com.lishid.openinv.util.setting.PlayerToggles; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -10,6 +11,7 @@ public class ToggleListener implements Listener { + @Keep @EventHandler private void onPlayerQuit(@NotNull PlayerQuitEvent event) { UUID playerId = event.getPlayer().getUniqueId();