From 52308e8432eb4e08e4069dc633557bc5b80dd09b Mon Sep 17 00:00:00 2001 From: Euphyllia Bierque Date: Fri, 1 Mar 2024 10:04:57 +0100 Subject: [PATCH] Fix SetBiome commande MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ne plus vérifier le joueur mais l'ile si elle est en execution Permettre de réutiliser la commande une fois le changement modifié --- .../skyllia/cache/CommandCacheExecution.java | 16 ++++++++-------- .../common/subcommands/SetBiomeSubCommand.java | 13 ++++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/plugin/src/main/java/fr/euphyllia/skyllia/cache/CommandCacheExecution.java b/plugin/src/main/java/fr/euphyllia/skyllia/cache/CommandCacheExecution.java index b09a74b..d526850 100644 --- a/plugin/src/main/java/fr/euphyllia/skyllia/cache/CommandCacheExecution.java +++ b/plugin/src/main/java/fr/euphyllia/skyllia/cache/CommandCacheExecution.java @@ -9,25 +9,25 @@ public class CommandCacheExecution { private static final ConcurrentHashMap> commandAlreadyExecution = new ConcurrentHashMap<>(); - public static boolean isAlreadyExecute(UUID playerId, String command) { - List listCmd = commandAlreadyExecution.getOrDefault(playerId, null); + public static boolean isAlreadyExecute(UUID uuid, String command) { + List listCmd = commandAlreadyExecution.getOrDefault(uuid, null); if (listCmd == null) return false; return listCmd.contains(command); } - public static void addCommandExecute(UUID playerId, String command) { - List listCmd = commandAlreadyExecution.getOrDefault(playerId, null); + public static void addCommandExecute(UUID uuid, String command) { + List listCmd = commandAlreadyExecution.getOrDefault(uuid, null); if (listCmd == null) { listCmd = new ArrayList<>(); } listCmd.add(command); - commandAlreadyExecution.put(playerId, listCmd); + commandAlreadyExecution.put(uuid, listCmd); } - public static void removeCommandExec(UUID playerId, String command) { - List listCmd = commandAlreadyExecution.getOrDefault(playerId, null); + public static void removeCommandExec(UUID uuid, String command) { + List listCmd = commandAlreadyExecution.getOrDefault(uuid, null); if (listCmd == null) return; listCmd.remove(command); - commandAlreadyExecution.put(playerId, listCmd); + commandAlreadyExecution.put(uuid, listCmd); } } diff --git a/plugin/src/main/java/fr/euphyllia/skyllia/commands/common/subcommands/SetBiomeSubCommand.java b/plugin/src/main/java/fr/euphyllia/skyllia/commands/common/subcommands/SetBiomeSubCommand.java index 32117f4..ddf225d 100644 --- a/plugin/src/main/java/fr/euphyllia/skyllia/commands/common/subcommands/SetBiomeSubCommand.java +++ b/plugin/src/main/java/fr/euphyllia/skyllia/commands/common/subcommands/SetBiomeSubCommand.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class SetBiomeSubCommand implements SubCommandInterface { @@ -52,17 +53,12 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N LanguageToml.sendMessage(plugin, player, LanguageToml.messageBiomeCommandNotEnoughArgs); return true; } - if (CommandCacheExecution.isAlreadyExecute(player.getUniqueId(), "biome")) { - LanguageToml.sendMessage(plugin, player, LanguageToml.messageCommandAlreadyExecution); - return true; - } Location playerLocation = player.getLocation(); int chunkLocX = playerLocation.getChunk().getX(); int chunkLocZ = playerLocation.getChunk().getZ(); String selectBiome = args[0]; - CommandCacheExecution.addCommandExecute(player.getUniqueId(), "biome"); try { Biome biome; try { @@ -84,6 +80,12 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N LanguageToml.sendMessage(plugin, player, LanguageToml.messagePlayerHasNotIsland); return true; } + final UUID islandId = island.getId(); + if (CommandCacheExecution.isAlreadyExecute(islandId, "biome")) { + LanguageToml.sendMessage(plugin, player, LanguageToml.messageCommandAlreadyExecution); + return true; + } + CommandCacheExecution.addCommandExecute(islandId, "biome"); Players executorPlayer = island.getMember(player.getUniqueId()); @@ -120,6 +122,7 @@ public boolean onCommand(@NotNull Main plugin, @NotNull CommandSender sender, @N }); } } + CommandCacheExecution.removeCommandExec(islandId, "biome"); } } catch (Exception e) { logger.log(Level.FATAL, e.getMessage(), e);