From c1493be6c1b4aeea8ed821bd25a7c4cee4b56d5f Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 3 Jul 2022 14:46:27 +0200 Subject: [PATCH 1/4] Added BlockFromToListener --- .../de/steamwar/fightsystem/FightSystem.java | 1 + .../listener/BlockFromToListener.java | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index b449484..4981e45 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -77,6 +77,7 @@ public class FightSystem extends JavaPlugin { new DenyInventoryMovement(); new EventJoin(); new Recording(); + new BlockFromToListener(); //new ResourcePack(); new Check(); new Shutdown(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java new file mode 100644 index 0000000..5d2bde6 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java @@ -0,0 +1,34 @@ +package de.steamwar.fightsystem.listener; + +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentListener; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockFromToEvent; + +public class BlockFromToListener implements Listener { + + public BlockFromToListener(){ + + new StateDependentListener(ArenaMode.All, FightState.All, this); + + } + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) { + + if (Fight.getBlueTeam().getSchemRegion().inRegion(event.getBlock()) + && Fight.getBlueTeam().getSchemRegion().inRegion(event.getToBlock())) { + return; + } + + if (Fight.getRedTeam().getSchemRegion().inRegion(event.getBlock()) + && Fight.getRedTeam().getSchemRegion().inRegion(event.getToBlock())) { + return; + } + + event.setCancelled(true); + } +} From 9774b28d571f7f30cd907b743ff81069c9a303e5 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 3 Jul 2022 14:50:25 +0200 Subject: [PATCH 2/4] Added Format --- .../steamwar/fightsystem/listener/BlockFromToListener.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java index 5d2bde6..23b0eac 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java @@ -10,15 +10,12 @@ import org.bukkit.event.block.BlockFromToEvent; public class BlockFromToListener implements Listener { - public BlockFromToListener(){ - + public BlockFromToListener(){ new StateDependentListener(ArenaMode.All, FightState.All, this); - } @EventHandler - public void onBlockFromTo(BlockFromToEvent event) { - + public void onBlockFromTo(BlockFromToEvent event) { if (Fight.getBlueTeam().getSchemRegion().inRegion(event.getBlock()) && Fight.getBlueTeam().getSchemRegion().inRegion(event.getToBlock())) { return; From c245f4c2ba1886cf72d92aff2b0be73069e13e17 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 3 Jul 2022 16:02:47 +0200 Subject: [PATCH 3/4] Deleted BlockFromToListener Updated DragonTeleport in Permanent class --- .../de/steamwar/fightsystem/FightSystem.java | 1 - .../listener/BlockFromToListener.java | 31 ------------------- .../fightsystem/listener/Permanent.java | 17 ++++++++++ 3 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 4981e45..b449484 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -77,7 +77,6 @@ public class FightSystem extends JavaPlugin { new DenyInventoryMovement(); new EventJoin(); new Recording(); - new BlockFromToListener(); //new ResourcePack(); new Check(); new Shutdown(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java deleted file mode 100644 index 23b0eac..0000000 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFromToListener.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.steamwar.fightsystem.listener; - -import de.steamwar.fightsystem.ArenaMode; -import de.steamwar.fightsystem.fight.Fight; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentListener; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockFromToEvent; - -public class BlockFromToListener implements Listener { - - public BlockFromToListener(){ - new StateDependentListener(ArenaMode.All, FightState.All, this); - } - - @EventHandler - public void onBlockFromTo(BlockFromToEvent event) { - if (Fight.getBlueTeam().getSchemRegion().inRegion(event.getBlock()) - && Fight.getBlueTeam().getSchemRegion().inRegion(event.getToBlock())) { - return; - } - - if (Fight.getRedTeam().getSchemRegion().inRegion(event.getBlock()) - && Fight.getRedTeam().getSchemRegion().inRegion(event.getToBlock())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index 6f0b877..f5506f6 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -29,10 +29,12 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.SpawnerSpawnEvent; @@ -147,4 +149,19 @@ public class Permanent implements Listener { if(!Config.ArenaLeaveable) e.getWorld().setAutoSave(false); } + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) { + if(event.getBlock().getType().equals(Material.DRAGON_EGG)) return; + + for (FightTeam team : Fight.teams()) { + if(team.getExtendRegion().inRegion(event.getBlock())){ + + if(team.getExtendRegion().inRegion(event.getToBlock())) return; + + } + } + + event.setCancelled(true); + } } From 1dad36c5dc2fc637ab6739e818027f5d68651aa4 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 3 Jul 2022 16:09:18 +0200 Subject: [PATCH 4/4] Fixed Inversion --- .../src/de/steamwar/fightsystem/listener/Permanent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index f5506f6..0d7d7e4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -152,7 +152,7 @@ public class Permanent implements Listener { @EventHandler public void onBlockFromTo(BlockFromToEvent event) { - if(event.getBlock().getType().equals(Material.DRAGON_EGG)) return; + if(!event.getBlock().getType().equals(Material.DRAGON_EGG)) return; for (FightTeam team : Fight.teams()) { if(team.getExtendRegion().inRegion(event.getBlock())){