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 1/2] 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); + } } -- 2.39.5 From b0c91b59fcc488d20948b5eb66900e125e9dd68c Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Sun, 22 Jan 2023 21:17:40 +0100 Subject: [PATCH 2/2] Anti water in Dispenser cleanup --- .../de/steamwar/fightsystem/listener/InFightInventory.java | 4 ---- .../src/de/steamwar/fightsystem/listener/Permanent.java | 6 ++++-- 2 files changed, 4 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 ffadab8..ad41d0a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -20,17 +20,13 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; -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; -import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryType; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index 2084291..e5f24a4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -29,6 +29,7 @@ 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.Block; import org.bukkit.block.data.type.Dispenser; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -166,11 +167,12 @@ public class Permanent implements Listener { @EventHandler public void onBlockDispense(BlockDispenseEvent e) { + Block block = e.getBlock(); - if(!Config.ArenaRegion.inRegion(e.getBlock())) + if(!Config.ArenaRegion.inRegion(block)) return; - if(e.getItem().getType() == Material.TNT || e.getBlock().getRelative(((Dispenser) e.getBlock().getBlockData()).getFacing()).isLiquid()) + if(e.getItem().getType() == Material.TNT || block.getRelative(((Dispenser) block.getBlockData()).getFacing()).isLiquid()) e.setCancelled(true); } } -- 2.39.5