From c3e1e93578e3887bfc24ff444dedb045c1a7d690 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 1 Apr 2020 11:59:37 +0200 Subject: [PATCH] Resetting Kit creator with creative inventory clear, FightTeam nametag fix for 1.15 Signed-off-by: Lixfel --- .../fightsystem/fight/FightTeam_10.java | 2 +- .../fightsystem/fight/FightTeam_12.java | 1 + .../fightsystem/fight/FightTeam_14.java | 1 + .../fightsystem/fight/FightTeam_9.java | 3 +++ .../listener/FreezeWorldStateListener.java | 4 ++-- .../fightsystem/utils/PersonalKitCreator.java | 22 +++++++++++++++++-- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java index d86fc97..659cca7 100644 --- a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java +++ b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java @@ -13,7 +13,7 @@ class FightTeam_10 { private FightTeam_10(){} static void setTeamColor(Team team, ChatColor color) { - FightTeam_8.setTeamColor(team, color); + FightTeam_9.setTeamColor(team, color); } static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java index 4580d87..9620fb3 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java @@ -33,6 +33,7 @@ class FightTeam_12 { static void setTeamColor(Team team, ChatColor color){ team.setColor(color); + team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java index e6cd189..6cf9c5c 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java @@ -39,6 +39,7 @@ class FightTeam_14 { static void setTeamColor(Team team, ChatColor color){ team.setColor(color); + team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); } static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java index 1d38af3..d6ec19a 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java @@ -14,6 +14,7 @@ class FightTeam_9 { static void setTeamColor(Team team, ChatColor color){ FightTeam_8.setTeamColor(team, color); + team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); } static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ @@ -23,4 +24,6 @@ class FightTeam_9 { static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); } + + } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/FreezeWorldStateListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/FreezeWorldStateListener.java index b7fd1bd..b9f59d6 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/FreezeWorldStateListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/FreezeWorldStateListener.java @@ -43,13 +43,13 @@ public class FreezeWorldStateListener extends BasicListener { @EventHandler public void onInventoryClick(InventoryClickEvent event) { - if(!PersonalKitCreator.inKitCreator(event.getWhoClicked())) + if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) event.setCancelled(true); } @EventHandler public void onInventoryDrag(InventoryDragEvent event) { - if(!PersonalKitCreator.inKitCreator(event.getWhoClicked())) + if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) event.setCancelled(true); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/PersonalKitCreator.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/PersonalKitCreator.java index 9811f81..95b10f5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/PersonalKitCreator.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/PersonalKitCreator.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -57,14 +58,31 @@ public class PersonalKitCreator implements Listener { } } - public static boolean inKitCreator(HumanEntity player){ - return openKitCreators.containsKey(player); + public static boolean notInKitCreator(HumanEntity player){ + return !openKitCreators.containsKey(player); } @EventHandler public void onInventoryClick(InventoryClickEvent e){ + if(!player.equals(e.getWhoClicked())) + return; + + //Deny bad items if(e.getCursor() != null && Config.ForbiddenItems.contains(e.getCursor().getType().name())) e.setCancelled(true); + + //Check for clear + if(e.getAction() != InventoryAction.PLACE_ALL) + return; + ItemStack[] items = e.getWhoClicked().getInventory().getContents(); + for(int i = 0; i < items.length; i++){ + ItemStack stack = items[i]; + if(stack != null && i != e.getSlot()) + return; + } + FightPlayer fightPlayer = Fight.getFightPlayer(player); + assert fightPlayer != null; + Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> fightPlayer.getKit().loadToPlayer(player), 1); } @EventHandler