From 6096fcad429975162d2eda97fd541d8b364282a8 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 8 Jan 2016 04:06:11 -0500 Subject: [PATCH] Fix hotbar issues --- .../games/gladiators/hotbar/HotbarEditor.java | 17 ++++++++++ .../games/gladiators/hotbar/HotbarLayout.java | 33 +++++++++++++++++++ .../gladiators/hotbar/HotbarPageListener.java | 14 ++++---- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 518b86d96..e9ecdeae7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -163,6 +163,23 @@ public class HotbarEditor extends MiniPlugin items.indexOf(arrows) - 9 ); + if (save.getArrows() > 8 || save.getArrows() < 0) + { + save.setArrows(save.getEmpty()); + } + if (save.getBow() > 8 || save.getBow() < 0) + { + save.setBow(save.getEmpty()); + } + if (save.getSword() > 8 || save.getSword() < 0) + { + save.setSword(save.getEmpty()); + } + if (save.getRod() > 8 || save.getRod() < 0) + { + save.setRod(save.getEmpty()); + } + _host.Manager.getArcadePlayer(player).put("hotbar", save.toDataSaveNumber()); player.sendMessage(F.main("Game", "Saved new hotbar layout!")); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java index 459f70411..ad4d024be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarLayout.java @@ -39,6 +39,26 @@ public class HotbarLayout return arrows; } + public void setSword(int sword) + { + this.sword = sword; + } + + public void setRod(int rod) + { + this.rod = rod; + } + + public void setBow(int bow) + { + this.bow = bow; + } + + public void setArrows(int arrows) + { + this.arrows = arrows; + } + public int toDataSaveNumber() { String str = ""; @@ -57,4 +77,17 @@ public class HotbarLayout return Integer.parseInt(str); } + + public int getEmpty() + { + for (int i = 0; i < 9; i++) + { + if (i == sword || i == rod || i == bow || i == arrows) + continue; + + return i; + } + + return 0; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java index 249983dd7..736de92df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarPageListener.java @@ -50,12 +50,6 @@ public class HotbarPageListener implements Listener System.out.println(e.getClickedInventory().getName() + " : " + e.getInventory().getName()); -// if ((e.getSlot() > 8 && e.getSlot() < 18)) -// { -// e.setCancelled(false); -// return; -// } - if (e.getCurrentItem().getType().equals(Material.REDSTONE_BLOCK)) { e.setCancelled(true); @@ -70,7 +64,7 @@ public class HotbarPageListener implements Listener if (e.getCurrentItem().getType().equals(Material.EMERALD_BLOCK)) { - if (e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ + if (!e.getAction().equals(InventoryAction.PICKUP_ALL)){ e.setCancelled(true); return; } @@ -81,6 +75,12 @@ public class HotbarPageListener implements Listener return; } + if ((e.getSlot() < 9 || e.getSlot() > 17)) + { + e.setCancelled(true); + return; + } + if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) { e.setCancelled(true);