Skip to content

Commit

Permalink
Re-add capitalization for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo committed Jul 28, 2024
1 parent 5e21419 commit 9166190
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,8 +19,8 @@
public final class PlayerToggles {

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"));

/**
* Get the AnyContainer toggle.
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion plugin/src/main/java/com/lishid/openinv/OpenInv.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,6 +11,7 @@

public class ToggleListener implements Listener {

@Keep
@EventHandler
private void onPlayerQuit(@NotNull PlayerQuitEvent event) {
UUID playerId = event.getPlayer().getUniqueId();
Expand Down

0 comments on commit 9166190

Please sign in to comment.