From 3645657683ff870eb0285322e36728056b1c1809 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 30 Aug 2020 21:37:10 +0200 Subject: [PATCH 1/7] Fix Bows in Chest --- src/de/steamwar/misslewars/MWTeam.java | 4 ++++ src/de/steamwar/misslewars/listener/ItemListener.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 8577a7c..8ab6c96 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -97,4 +97,8 @@ public class MWTeam { public String getColoredName() { return color.toString() + teamName; } + + public static ItemStack getBow() { + return bow; + } } diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index e893f63..273937d 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -11,14 +11,17 @@ 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.InventoryCloseEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -78,4 +81,12 @@ public class ItemListener extends BasicListener { }, Config.ShieldFlyTime); } } + + @EventHandler(ignoreCancelled = true) + public void onInventoryClose(InventoryCloseEvent event) { + if(event.getInventory().contains(MWTeam.getBow())) { + event.getInventory().setItem(event.getInventory().first(MWTeam.getBow()), new ItemStack(Material.AIR)); + event.getPlayer().getInventory().addItem(MWTeam.getBow()); + } + } } -- 2.39.5 From 1775f4d366c006677a0e8defbb2249b3dc8ada4b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 30 Aug 2020 21:52:13 +0200 Subject: [PATCH 2/7] Fix Bows in Chest --- src/de/steamwar/misslewars/listener/ItemListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index 273937d..5b25cda 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -84,8 +84,8 @@ public class ItemListener extends BasicListener { @EventHandler(ignoreCancelled = true) public void onInventoryClose(InventoryCloseEvent event) { - if(event.getInventory().contains(MWTeam.getBow())) { - event.getInventory().setItem(event.getInventory().first(MWTeam.getBow()), new ItemStack(Material.AIR)); + if(event.getInventory().contains(Material.BOW)) { + event.getInventory().setItem(event.getInventory().first(Material.BOW), new ItemStack(Material.AIR)); event.getPlayer().getInventory().addItem(MWTeam.getBow()); } } -- 2.39.5 From 1a721b2f4958732ef622a0bbc110d18c250f575d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 31 Aug 2020 14:09:02 +0200 Subject: [PATCH 3/7] Cancel Putting bow in Chest --- .../misslewars/listener/ItemListener.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index 5b25cda..03304e6 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -21,8 +21,12 @@ 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; @@ -82,11 +86,25 @@ public class ItemListener extends BasicListener { } } - @EventHandler(ignoreCancelled = true) - public void onInventoryClose(InventoryCloseEvent event) { - if(event.getInventory().contains(Material.BOW)) { - event.getInventory().setItem(event.getInventory().first(Material.BOW), new ItemStack(Material.AIR)); - event.getPlayer().getInventory().addItem(MWTeam.getBow()); - } + @EventHandler + public void onInventoryClick(InventoryClickEvent event) { + Inventory clicked = event.getClickedInventory(); + if(event.getClick().isShiftClick()){ + ItemStack clickedOn = event.getCurrentItem(); + + if( + clickedOn != null && + event.getView().getTopInventory().getType() != InventoryType.CRAFTING && + event.getCurrentItem().getType() != Material.BOW && + clicked == event.getWhoClicked().getInventory()) + event.setCancelled(true); + }else if ( + clicked != event.getWhoClicked().getInventory() && + clicked != null && + clicked.getType() != InventoryType.PLAYER && + event.getCurrentItem().getType() != Material.BOW && + event.getCursor() != null && + event.getCursor().getType() != Material.AIR) + event.setCancelled(true); } } -- 2.39.5 From 82dc627e36dd1b24dc7afa39385c864d1629f535 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 31 Aug 2020 19:56:30 +0200 Subject: [PATCH 4/7] Removed Only Bow If Clause --- src/de/steamwar/misslewars/listener/ItemListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index 03304e6..275c99a 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -95,14 +95,12 @@ public class ItemListener extends BasicListener { if( clickedOn != null && event.getView().getTopInventory().getType() != InventoryType.CRAFTING && - event.getCurrentItem().getType() != Material.BOW && clicked == event.getWhoClicked().getInventory()) event.setCancelled(true); }else if ( clicked != event.getWhoClicked().getInventory() && clicked != null && clicked.getType() != InventoryType.PLAYER && - event.getCurrentItem().getType() != Material.BOW && event.getCursor() != null && event.getCursor().getType() != Material.AIR) event.setCancelled(true); -- 2.39.5 From c038d8a229800592c1e665c7274c250586fb5106 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 3 Sep 2020 15:11:47 +0200 Subject: [PATCH 5/7] Fixes Item Taking From Chest Pre Fight --- src/de/steamwar/misslewars/listener/ItemListener.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index 275c99a..ae46b19 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -89,6 +89,10 @@ public class ItemListener extends BasicListener { @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(); @@ -102,7 +106,7 @@ public class ItemListener extends BasicListener { clicked != null && clicked.getType() != InventoryType.PLAYER && event.getCursor() != null && - event.getCursor().getType() != Material.AIR) + event.getCursor().getType() != Material.AIR ) event.setCancelled(true); } } -- 2.39.5 From 92c37a69c604fa7ae7f33cf5c5fcda1aded10b7c Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 3 Sep 2020 16:13:16 +0200 Subject: [PATCH 6/7] Removed Unused Method --- src/de/steamwar/misslewars/MWTeam.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 8ab6c96..e4f40d7 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -98,7 +98,4 @@ public class MWTeam { return color.toString() + teamName; } - public static ItemStack getBow() { - return bow; - } } -- 2.39.5 From 0235db3e5f905340f4f735a12a19f42cb660a450 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 3 Sep 2020 18:08:04 +0200 Subject: [PATCH 7/7] Removed Open Chests --- .../misslewars/listener/ArenaListener.java | 10 ++++++ .../misslewars/listener/ItemListener.java | 31 ------------------- 2 files changed, 10 insertions(+), 31 deletions(-) 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); - } } -- 2.39.5