From 914bf4f353a5e510ab5203375462b4071498eb6f Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 22 Jan 2023 21:12:47 +0100 Subject: [PATCH] Anti water in Dispenser --- .../fightsystem/listener/InFightInventory.java | 8 ++------ .../de/steamwar/fightsystem/listener/Permanent.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java index 85eb983..ffadab8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -24,7 +24,9 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.block.data.type.Dispenser; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -74,10 +76,4 @@ public class InFightInventory implements Listener { } } } - - @EventHandler - public void onBlockDispense(BlockDispenseEvent e) { - if(Config.ArenaRegion.inRegion(e.getBlock()) && e.getItem().getType() == Material.TNT) - e.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 693eb88..2084291 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.StateDependentListener; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.block.data.type.Dispenser; 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.BlockDispenseEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.PlayerDeathEvent; @@ -161,4 +163,14 @@ public class Permanent implements Listener { event.setCancelled(true); } + + @EventHandler + public void onBlockDispense(BlockDispenseEvent e) { + + if(!Config.ArenaRegion.inRegion(e.getBlock())) + return; + + if(e.getItem().getType() == Material.TNT || e.getBlock().getRelative(((Dispenser) e.getBlock().getBlockData()).getFacing()).isLiquid()) + e.setCancelled(true); + } }