▶️ ЗАБЕРИ СВОИ 8 ПОДАРКОВ 🎁 ПРИ СОЗДАНИИ СВОЕГО МАЙНКРАФТ СЕРВЕРА
Моды/oaexploits
536
4
Все версииoaexploits 1.3.61

oaexploits 1.3.61

Release1 г. назад

Список изменений

Fixes Implemented

  1. Fixed Bug Where Players Could Not Drop Items or Interact with Them:

    Previously, the plugin's GUI implementation inadvertently prevented players from dropping items or interacting with their inventories outside of the custom GUI. This was likely due to the event handling logic being too restrictive and canceling interactions even when they shouldn't have been.

    How It Was Fixed:

    • The onInventoryClick method was updated to specifically check if the interaction was within the custom GUI.
    • A Set<UUID> named playersWithGuiOpen was used to track which players have the custom GUI open. This ensures that only those players are affected by the interaction restrictions, allowing all other players to interact with their inventories normally.
  2. Fixed GUI Reload Not Working:

    The previous implementation of the GUI's reload functionality did not properly reload the configuration from the config.yml file. This was because the configuration reload command was not being executed correctly from within the GUI.

    How It Was Fixed:

    • A new command ReloadCommand was implemented and registered to handle reloading the plugin configuration.
    • The reloadPluginConfig method in the OaExploitsGUI class was updated to dispatch the oaexploits reload command programmatically. This ensures that when the "Reload Configuration" item in the GUI is clicked, the ReloadCommand is executed, which correctly reloads the configuration and updates any necessary settings.

Detailed Steps for Each Fix

  1. Fixing Player Interaction with Items:

    In the OaExploitsGUI class:

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if (!(event.getWhoClicked() instanceof Player player)) return;
    
        UUID playerId = player.getUniqueId();
        if (!playersWithGuiOpen.contains(playerId)) return; // Only handle events for players with the GUI open
    
        long currentTime = System.currentTimeMillis();
    
        // Prevent rapid toggling by using a cooldown
        if (lastInteractionTimes.containsKey(playerId) && currentTime - lastInteractionTimes.get(playerId) < 500) {
            event.setCancelled(true);
            return;
        }
        lastInteractionTimes.put(playerId, currentTime);
    
        Inventory inventory = event.getClickedInventory();
        if (inventory == null || event.getCurrentItem() == null || !event.getCurrentItem().hasItemMeta()) return;
    
        // Check if the clicked inventory is our custom GUI
        if (event.getView().title().equals(GUI_TITLE)) {
            event.setCancelled(true);
    
            ItemStack clickedItem = event.getCurrentItem();
            Component displayName = clickedItem.getItemMeta().displayName();
    
            if (!player.isOp()) {
                player.sendMessage(Component.text("You do not have permission to change these settings.").color(NamedTextColor.RED));
                return;
            }
    
            if (Objects.equals(displayName, TOGGLE_ILLEGAL_ITEMS)) {
                handleConfigOptionClick(player, "removal-options.remove-illegal-items", "Illegal Items Removal");
            } else if (Objects.equals(displayName, TOGGLE_ADMIN_ALERTS)) {
                handleConfigOptionClick(player, "admin-alerts.enabled", "Admin Alerts");
            } else if (Objects.equals(displayName, TOGGLE_SHULKER_CLEAN)) {
                handleConfigOptionClick(player, "removal-options.clean-shulkers-on-place", "Shulker Box Cleaning");
            } else if (Objects.equals(displayName, RELOAD_CONFIGURATION)) {
                reloadPluginConfig(player);
            }
    
            // Refresh the GUI to update statuses
            Bukkit.getScheduler().runTaskLater(plugin, () -> refreshSettingsGUI(player), 1);
        }
    }
    

    This logic ensures that inventory interactions are only canceled when the player is interacting with the custom GUI, allowing normal interactions elsewhere.

  2. Fixing GUI Reload Functionality:

    In the ReloadCommand class:

    package fanlim.dev.oaexploits.commands;
    
    import fanlim.dev.oaexploits.Oaexploits;
    import fanlim.dev.oaexploits.antiexploits.AntiIllegalItems;
    import fanlim.dev.oaexploits.chunks.ChunkLimiter;
    import fanlim.dev.oaexploits.players.PlayerDeopOnLeave;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.jetbrains.annotations.NotNull;
    
    public class ReloadCommand implements CommandExecutor {
    
        private final Oaexploits plugin;
        private final AntiIllegalItems antiIllegalItems;
        private final ChunkLimiter chunkLimiter;
        private final PlayerDeopOnLeave playerDeopOnLeave;
    
        public ReloadCommand(@NotNull Oaexploits plugin,
                             @NotNull AntiIllegalItems antiIllegalItems, @NotNull ChunkLimiter chunkLimiter,
                             @NotNull PlayerDeopOnLeave playerDeopOnLeave) {
            this.plugin = plugin;
            this.antiIllegalItems = antiIllegalItems;
            this.chunkLimiter = chunkLimiter;
            this.playerDeopOnLeave = playerDeopOnLeave;
        }
    
        @Override
        public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
                                 @NotNull String label, @NotNull String[] args) {
            if (command.getName().equalsIgnoreCase("oaexploits")) {
                if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                    plugin.reloadConfig();
                    antiIllegalItems.reloadConfigValues();
                    chunkLimiter.reloadChunkLimiterConfig();
                    playerDeopOnLeave.reloadConfigValues();
                    sender.sendMessage("Oaexploits configuration reloaded.");
                    return true;
                }
            }
            return false;
        }
    }
    

    In the OaExploitsGUI class, the reloadPluginConfig method dispatches the oaexploits reload command:

    private void reloadPluginConfig(Player player) {
        CommandSender sender = Bukkit.getConsoleSender();
        Bukkit.dispatchCommand(sender, "oaexploits reload");
        player.sendMessage(Component.text("Configuration reloaded.").color(NamedTextColor.GREEN));
    }
    

Certainly! Here's the complete explanation with the code details included:

Fixes Implemented

  1. Fixed Bug Where Players Could Not Drop Items or Interact with Them:

    Problem: The plugin's GUI implementation inadvertently prevented players from dropping items or interacting with their inventories outside of the custom GUI.

    Solution:

    • The event handling logic was updated to specifically check if the interaction was within the custom GUI.
    • A set was used to track which players have the custom GUI open. This ensures that only those players are affected by the interaction restrictions, allowing all other players to interact with their inventories normally.

    Code Changes:

    In the OaExploitsGUI class:

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if (!(event.getWhoClicked() instanceof Player player)) return;
    
        UUID playerId = player.getUniqueId();
        if (!playersWithGuiOpen.contains(playerId)) return; // Only handle events for players with the GUI open
    
        long currentTime = System.currentTimeMillis();
    
        // Prevent rapid toggling by using a cooldown
        if (lastInteractionTimes.containsKey(playerId) && currentTime - lastInteractionTimes.get(playerId) < 500) {
            event.setCancelled(true);
            return;
        }
        lastInteractionTimes.put(playerId, currentTime);
    
        Inventory inventory = event.getClickedInventory();
        if (inventory == null || event.getCurrentItem() == null || !event.getCurrentItem().hasItemMeta()) return;
    
        // Check if the clicked inventory is our custom GUI
        if (event.getView().title().equals(GUI_TITLE)) {
            event.setCancelled(true);
    
            ItemStack clickedItem = event.getCurrentItem();
            Component displayName = clickedItem.getItemMeta().displayName();
    
            if (!player.isOp()) {
                player.sendMessage(Component.text("You do not have permission to change these settings.").color(NamedTextColor.RED));
                return;
            }
    
            if (Objects.equals(displayName, TOGGLE_ILLEGAL_ITEMS)) {
                handleConfigOptionClick(player, "removal-options.remove-illegal-items", "Illegal Items Removal");
            } else if (Objects.equals(displayName, TOGGLE_ADMIN_ALERTS)) {
                handleConfigOptionClick(player, "admin-alerts.enabled", "Admin Alerts");
            } else if (Objects.equals(displayName, TOGGLE_SHULKER_CLEAN)) {
                handleConfigOptionClick(player, "removal-options.clean-shulkers-on-place", "Shulker Box Cleaning");
            } else if (Objects.equals(displayName, RELOAD_CONFIGURATION)) {
                reloadPluginConfig(player);
            }
    
            // Refresh the GUI to update statuses
            Bukkit.getScheduler().runTaskLater(plugin, () -> refreshSettingsGUI(player), 1);
        }
    }
    

    This logic ensures that inventory interactions are only canceled when the player is interacting with the custom GUI, allowing normal interactions elsewhere.

  2. Fixed GUI Reload Not Working:

    Problem: The previous implementation of the GUI's reload functionality did not properly reload the configuration from the config.yml file.

    Solution:

    • A new command ReloadCommand was implemented and registered to handle reloading the plugin configuration.
    • The method in the GUI class that handles the reload was updated to programmatically execute the reload command. This ensures that when the "Reload Configuration" item in the GUI is clicked, the reload command is executed, which correctly reloads the configuration and updates any necessary settings.

    Code Changes:

    In the ReloadCommand class:

    package fanlim.dev.oaexploits.commands;
    
    import fanlim.dev.oaexploits.Oaexploits;
    import fanlim.dev.oaexploits.antiexploits.AntiIllegalItems;
    import fanlim.dev.oaexploits.chunks.ChunkLimiter;
    import fanlim.dev.oaexploits.players.PlayerDeopOnLeave;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.jetbrains.annotations.NotNull;
    
    public class ReloadCommand implements CommandExecutor {
    
        private final Oaexploits plugin;
        private final AntiIllegalItems antiIllegalItems;
        private final ChunkLimiter chunkLimiter;
        private final PlayerDeopOnLeave playerDeopOnLeave;
    
        public ReloadCommand(@NotNull Oaexploits plugin,
                             @NotNull AntiIllegalItems antiIllegalItems, @NotNull ChunkLimiter chunkLimiter,
                             @NotNull PlayerDeopOnLeave playerDeopOnLeave) {
            this.plugin = plugin;
            this.antiIllegalItems = antiIllegalItems;
            this.chunkLimiter = chunkLimiter;
            this.playerDeopOnLeave = playerDeopOnLeave;
        }
    
        @Override
        public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
                                 @NotNull String label, @NotNull String[] args) {
            if (command.getName().equalsIgnoreCase("oaexploits")) {
                if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                    plugin.reloadConfig();
                    antiIllegalItems.reloadConfigValues();
                    chunkLimiter.reloadChunkLimiterConfig();
                    playerDeopOnLeave.reloadConfigValues();
                    sender.sendMessage("Oaexploits configuration reloaded.");
                    return true;
                }
            }
            return false;
        }
    }
    

    In the OaExploitsGUI class, the reloadPluginConfig method dispatches the oaexploits reload command:

    private void reloadPluginConfig(Player player) {
        CommandSender sender = Bukkit.getConsoleSender();
        Bukkit.dispatchCommand(sender, "oaexploits reload");
        player.sendMessage(Component.text("Configuration reloaded.").color(NamedTextColor.GREEN));
    }
    

    This setup ensures that when the "Reload Configuration" item is clicked in the GUI, the oaexploits reload command is executed, which reloads the plugin's configuration and updates the settings as needed.

Additional Feature

  • Reload Command Usable In-Game: The new reload command can also be used in-game by executing /oaexploits reload. This allows administrators to reload the plugin configuration directly from the game without needing to access the server console.

Benefits of the Fixes

  1. Improved User Experience: Players can now interact with their inventories and drop items normally when not using the custom GUI, improving overall gameplay experience.

  2. Reliable Configuration Reload: The configuration reload functionality now works as expected. Admins can reload the configuration via the GUI, ensuring that any changes to the config.yml file are applied without needing to restart the server.

  3. Convenient In-Game Administration: Administrators can easily reload the plugin configuration while in-game using the /oaexploits reload command, making server management more convenient.

Файлы

oaexploits-1.3.61.jar(42.71 KiB)
Основной
Скачать

Метаданные

Канал релиза

Release

Номер версии

1.3.61

Загрузчики

Bukkit
Paper
Purpur
Spigot

Версии игры

1.8–1.21

Загрузок

33

Дата публикации

1 г. назад

Загрузил

ID версии

Главная