diff --git a/pom.xml b/pom.xml index 7cdf099b04..57d6c680ec 100644 --- a/pom.xml +++ b/pom.xml @@ -387,7 +387,7 @@ - com.github.MockBukkit + com.github.mockbukkit MockBukkit c7cc678834 test diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index ce4fea9b02..c6d74824a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -223,6 +223,15 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { String title = "&4" + Slimefun.getLocalization().getResourceString(p, "tooltips.results"); ChestMenu menu = new ChestMenu(title); + // Prevent both shift-clicking and number key usage + menu.setPlayerInventoryClickable(false); + menu.setEmptySlotsClickable(false); + + // Add click handler to explicitly deny shift and number key actions + menu.addPlayerInventoryClickHandler((player, slot, item, action) -> { + return false; // Deny all player inventory interactions + }); + for (int slot : backgroundSlots) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index 47574fb2ca..1aa57958c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -44,9 +44,9 @@ * The {@link GPSNetwork} is a manager class for all {@link GPSTransmitter Transmitters} and waypoints. * There can only be one instance of this class per {@link Server}. * It is also responsible for teleportation and resource management. - * + * * @author TheBusyBiscuit - * + * * @see TeleportationManager * @see ResourceManager * @@ -64,7 +64,7 @@ public class GPSNetwork { /** * This constructs a new {@link GPSNetwork}. * Note that this network is per {@link Server} and not per {@link Player}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -74,7 +74,7 @@ public GPSNetwork(@Nonnull Slimefun plugin) { /** * This method updates the status of a {@link GPSTransmitter}. - * + * * @param l * The {@link Location} of the {@link GPSTransmitter} * @param uuid @@ -96,10 +96,10 @@ public void updateTransmitter(@Nonnull Location l, @Nonnull UUID uuid, boolean o * This method calculates the GPS complexity for the given {@link UUID}. * The complexity is determined by the Y level of each {@link GPSTransmitter} * multiplied by the multiplier of that transmitter. - * + * * @param uuid * The {@link UUID} who to calculate it for - * + * * @return The network complexity for that {@link UUID} */ public int getNetworkComplexity(@Nonnull UUID uuid) { @@ -124,10 +124,10 @@ public int getNetworkComplexity(@Nonnull UUID uuid) { /** * This method returns the amount of {@link GPSTransmitter Transmitters} for the * given {@link UUID}. - * + * * @param uuid * The {@link UUID} who these transmitters belong to - * + * * @return The amount of transmitters */ public int countTransmitters(@Nonnull UUID uuid) { @@ -138,13 +138,22 @@ public int countTransmitters(@Nonnull UUID uuid) { /** * This method opens the {@link GPSTransmitter} control panel to the given * {@link Player}. - * + * * @param p * The {@link Player} */ public void openTransmitterControlPanel(@Nonnull Player p) { ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); + // Prevent both shift-clicking and number key usage + menu.setPlayerInventoryClickable(false); + menu.setEmptySlotsClickable(false); + + // Add click handler to explicitly deny shift and number key actions + menu.addPlayerInventoryClickHandler((player, slot, item, action) -> { + return false; + }); + for (int slot : border) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } @@ -192,14 +201,14 @@ public void openTransmitterControlPanel(@Nonnull Player p) { * The icon is dependent on the {@link Environment} of the waypoint's {@link World}. * However if the name of this waypoint indicates that this is actually a deathmarker * then a different texture will be used. - * + * * Otherwise it will return a globe, a nether or end sphere according to the {@link Environment}. - * + * * @param name * The name of a waypoint * @param environment * The {@link Environment} of the waypoint's {@link World} - * + * * @return An icon for this waypoint */ @ParametersAreNonnullByDefault @@ -228,6 +237,15 @@ public void openWaypointControlPanel(@Nonnull Player p) { PlayerProfile.get(p, profile -> { ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); + // Prevent both shift-clicking and number key usage + menu.setPlayerInventoryClickable(false); + menu.setEmptySlotsClickable(false); + + // Add click handler to explicitly deny shift and number key actions + menu.addPlayerInventoryClickHandler((player, slot, item, action) -> { + return false; // Deny all player inventory interactions + }); + for (int slot : border) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } @@ -273,7 +291,7 @@ public void openWaypointControlPanel(@Nonnull Player p) { /** * This method will prompt the given {@link Player} to enter a name for a waypoint. * After entering the name, it will be added to his waypoint list. - * + * * @param p * The {@link Player} who should get a new waypoint * @param l @@ -298,7 +316,7 @@ public void createWaypoint(@Nonnull Player p, @Nonnull Location l) { /** * This method adds a new waypoint with the given name and {@link Location} for that {@link Player}. - * + * * @param p * The {@link Player} to get the new waypoint * @param name @@ -343,10 +361,10 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati /** * This method returns a {@link Set} of {@link Location Locations} for all {@link GPSTransmitter Transmitters} * owned by the given {@link UUID}. - * + * * @param uuid * The {@link UUID} owning those transmitters - * + * * @return A {@link Set} with all {@link Location Locations} of transmitters for this {@link UUID} */ @Nonnull @@ -357,7 +375,7 @@ public Set getTransmitters(@Nonnull UUID uuid) { /** * This returns the {@link TeleportationManager} for this {@link GPSNetwork}. * It is responsible for all actions that relate to the {@link Teleporter}. - * + * * @return The {@link TeleportationManager} for this {@link GPSNetwork} */ @Nonnull @@ -368,7 +386,7 @@ public TeleportationManager getTeleportationManager() { /** * This returns the {@link ResourceManager} for this {@link GPSNetwork}. * Use this to access {@link GEOResource GEOResources}. - * + * * @return The {@link ResourceManager} for this {@link GPSNetwork} */ @Nonnull diff --git a/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/ClickAction.java b/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/ClickAction.java index 4ad692a6e1..de4ab4d7ca 100644 --- a/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/ClickAction.java +++ b/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/ClickAction.java @@ -1,5 +1,7 @@ package me.mrCookieSlime.CSCoreLibPlugin.general.Inventory; +import org.bukkit.event.inventory.InventoryClickEvent; + /** * An old remnant of CS-CoreLib. * This will be removed once we updated everything. @@ -9,10 +11,18 @@ public class ClickAction { private boolean right; private boolean shift; + private boolean numberKey; public ClickAction(boolean rightClicked, boolean shiftClicked) { this.right = rightClicked; this.shift = shiftClicked; + this.numberKey = false; + } + + public ClickAction(InventoryClickEvent e) { + this.right = e.isRightClick(); + this.shift = e.isShiftClick(); + this.numberKey = e.getClick().name().equals("NUMBER_KEY"); } public boolean isRightClicked() { @@ -22,5 +32,8 @@ public boolean isRightClicked() { public boolean isShiftClicked() { return shift; } - + + public boolean isNumberKey() { + return numberKey; + } } diff --git a/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/MenuListener.java b/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/MenuListener.java index 1647e5aeee..615d5c7770 100644 --- a/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/MenuListener.java +++ b/src/main/java/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/MenuListener.java @@ -48,12 +48,12 @@ public void onClick(InventoryClickEvent e) { if (handler == null) { e.setCancelled(!menu.isEmptySlotsClickable() && (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR)); } else if (handler instanceof AdvancedMenuClickHandler) { - e.setCancelled(!((AdvancedMenuClickHandler) handler).onClick(e, (Player) e.getWhoClicked(), e.getSlot(), e.getCursor(), new ClickAction(e.isRightClick(), e.isShiftClick()))); + e.setCancelled(!((AdvancedMenuClickHandler) handler).onClick(e, (Player) e.getWhoClicked(), e.getSlot(), e.getCursor(), new ClickAction(e))); } else { - e.setCancelled(!handler.onClick((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), new ClickAction(e.isRightClick(), e.isShiftClick()))); + e.setCancelled(!handler.onClick((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), new ClickAction(e))); } } else { - e.setCancelled(!menu.getPlayerInventoryClickHandler().onClick((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), new ClickAction(e.isRightClick(), e.isShiftClick()))); + e.setCancelled(!menu.getPlayerInventoryClickHandler().onClick((Player) e.getWhoClicked(), e.getSlot(), e.getCurrentItem(), new ClickAction(e))); } } }