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] 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); + } +}