Compatibility
Minecraft: Java Edition
Platforms
Creators
Details
Changelog
Fixes Implemented
-
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
onInventoryClickmethod was updated to specifically check if the interaction was within the custom GUI. - A
Set<UUID>namedplayersWithGuiOpenwas 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.
- The
-
Fixed GUI Reload Not Working:
The previous implementation of the GUI's reload functionality did not properly reload the configuration from the
config.ymlfile. This was because the configuration reload command was not being executed correctly from within the GUI.How It Was Fixed:
- A new command
ReloadCommandwas implemented and registered to handle reloading the plugin configuration. - The
reloadPluginConfigmethod in theOaExploitsGUIclass was updated to dispatch theoaexploits reloadcommand programmatically. This ensures that when the "Reload Configuration" item in the GUI is clicked, theReloadCommandis executed, which correctly reloads the configuration and updates any necessary settings.
- A new command
Detailed Steps for Each Fix
-
Fixing Player Interaction with Items:
In the
OaExploitsGUIclass:@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.
-
Fixing GUI Reload Functionality:
In the
ReloadCommandclass: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
OaExploitsGUIclass, thereloadPluginConfigmethod dispatches theoaexploits reloadcommand: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
-
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
OaExploitsGUIclass:@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.
-
Fixed GUI Reload Not Working:
Problem: The previous implementation of the GUI's reload functionality did not properly reload the configuration from the
config.ymlfile.Solution:
- A new command
ReloadCommandwas 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
ReloadCommandclass: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
OaExploitsGUIclass, thereloadPluginConfigmethod dispatches theoaexploits reloadcommand: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 reloadcommand is executed, which reloads the plugin's configuration and updates the settings as needed. - A new command
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
-
Improved User Experience: Players can now interact with their inventories and drop items normally when not using the custom GUI, improving overall gameplay experience.
-
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.ymlfile are applied without needing to restart the server. -
Convenient In-Game Administration: Administrators can easily reload the plugin configuration while in-game using the
/oaexploits reloadcommand, making server management more convenient.
Files
Metadata
Release channel
ReleaseVersion number
1.3.61Loaders
Game versions
1.8–1.21Downloads
33Publication date
July 5, 2024 at 12:06 PMPublisher

fanlim
owner



