diff --git a/src/de/steamwar/misslewars/listener/ArenaListener.java b/src/de/steamwar/misslewars/listener/ArenaListener.java index d29db7f..6f3e898 100644 --- a/src/de/steamwar/misslewars/listener/ArenaListener.java +++ b/src/de/steamwar/misslewars/listener/ArenaListener.java @@ -8,6 +8,8 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPickupArrowEvent; @@ -57,4 +59,12 @@ public class ArenaListener extends BasicListener { public void onHunger(FoodLevelChangeEvent e){ e.setCancelled(true); } + + @EventHandler(ignoreCancelled = true) + public void onInventoryOpen(InventoryOpenEvent event) { + if(event.getView().getType() != InventoryType.PLAYER && + event.getView().getType() != InventoryType.CRAFTING && + event.getView().getType() != InventoryType.CREATIVE) + event.setCancelled(true); + } } diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index ae46b19..e893f63 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -11,22 +11,15 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; -import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.items.SpecialItem; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.entity.ProjectileLaunchEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import java.io.File; @@ -85,28 +78,4 @@ public class ItemListener extends BasicListener { }, Config.ShieldFlyTime); } } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - Inventory clicked = event.getClickedInventory(); - if(MissileWars.getFightState() != FightState.FIGHTING) { - event.setCancelled(true); - return; - } - if(event.getClick().isShiftClick()){ - ItemStack clickedOn = event.getCurrentItem(); - - if( - clickedOn != null && - event.getView().getTopInventory().getType() != InventoryType.CRAFTING && - clicked == event.getWhoClicked().getInventory()) - event.setCancelled(true); - }else if ( - clicked != event.getWhoClicked().getInventory() && - clicked != null && - clicked.getType() != InventoryType.PLAYER && - event.getCursor() != null && - event.getCursor().getType() != Material.AIR ) - event.setCancelled(true); - } }