Fix hotbar issues

This commit is contained in:
Shaun Bennett 2016-01-08 04:06:11 -05:00
parent 504d9d508c
commit 6096fcad42
3 changed files with 57 additions and 7 deletions

View File

@ -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!"));
}

View File

@ -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;
}
}

View File

@ -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);