From 09adc97a2018d7ee6d99284794d1c8c62c18d506 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 18 Jan 2023 21:37:04 +0100 Subject: [PATCH 1/4] added arena afk stopper --- FightSystem_Core/src/config.yml | 2 +- .../src/de/steamwar/fightsystem/Config.java | 2 +- .../countdown/NoPlayersOnlineCountdown.java | 21 +++---------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/FightSystem_Core/src/config.yml b/FightSystem_Core/src/config.yml index 711d1d2..14a9fed 100644 --- a/FightSystem_Core/src/config.yml +++ b/FightSystem_Core/src/config.yml @@ -20,7 +20,7 @@ Ranks: [] # Disables ranks for this schematic type if missing Times: # Time in seconds the server stops after starting if nobody joins - NoPlayersOnlineDuration: 30 # defaults to 30 if missing + NoPlayersOnlineDuration: 300 # defaults to 300 if missing # Time in seconds the team leaders have to choose their schematic PreSchemPasteDuration: 120 # defaults to 120 if missing # Time in seconds for preparing diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 1123289..f1affb4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -155,7 +155,7 @@ public class Config { } FileConfiguration worldconfig = YamlConfiguration.loadConfiguration(worldConfigFile); - NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 30); + NoPlayerOnlineDuration = config.getInt("Times.NoPlayersOnlineDuration", 300); PreSchemPasteDuration = config.getInt("Times.PreSchemPasteDuration", 120); SetupDuration = config.getInt("Times.SetupDuration", 300); PreFightDuration = config.getInt("Times.PreFightDuration", 30); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java index 11cb3c9..94e54e2 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java @@ -23,31 +23,16 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; -import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.Message; import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -public class NoPlayersOnlineCountdown extends Countdown implements Listener { +public class NoPlayersOnlineCountdown extends Countdown { public NoPlayersOnlineCountdown() { super(Config.NoPlayerOnlineDuration, new Message("SHUTDOWN_COUNTDOWN"), null, false); - new StateDependentListener(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); - new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this) { - @Override - public void enable() { - if(Bukkit.getOnlinePlayers().isEmpty()) - super.enable(); - } - }; - } - - @EventHandler - public void handlePlayerJoin(PlayerJoinEvent event) { - disable(); + if (!Config.ArenaLeaveable) + new StateDependentCountdown(ArenaMode.AntiReplay, FightState.PreLeaderSetup, this); } @Override 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 2/4] 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); + } } 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 3/4] 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); } } From 239c0bf5f6b3be4fb79c319fdbbe1fabc89da85a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 22 Jan 2023 22:19:53 +0100 Subject: [PATCH 4/4] Fix 1.8 to 1.12 dispenser Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/utils/FlatteningWrapper14.java | 6 ++++++ .../de/steamwar/fightsystem/utils/FlatteningWrapper8.java | 5 +++++ .../src/de/steamwar/fightsystem/listener/Permanent.java | 4 ++-- .../de/steamwar/fightsystem/utils/FlatteningWrapper.java | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java index 5d907c7..86b883f 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java @@ -25,6 +25,7 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Dispenser; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockDataMeta; @@ -111,4 +112,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper { public boolean checkPistonMoving(Block block) { return block.getType() == Material.MOVING_PISTON; } + + @Override + public boolean isFacingWater(Block dispenser) { + return dispenser.getRelative(((Dispenser) dispenser.getBlockData()).getFacing()).isLiquid(); + } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java index e84fe55..e05b74b 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java @@ -77,4 +77,9 @@ public class FlatteningWrapper8 implements FlatteningWrapper { public boolean checkPistonMoving(Block block) { return block.getType() == Material.PISTON_MOVING_PIECE; } + + @Override + public boolean isFacingWater(Block dispenser) { + return false; + } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java index e5f24a4..d10c7c8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java @@ -26,11 +26,11 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.FlatteningWrapper; 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; import org.bukkit.event.EventPriority; @@ -172,7 +172,7 @@ public class Permanent implements Listener { if(!Config.ArenaRegion.inRegion(block)) return; - if(e.getItem().getType() == Material.TNT || block.getRelative(((Dispenser) block.getBlockData()).getFacing()).isLiquid()) + if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block)) e.setCancelled(true); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java index fba2c30..5a9804d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java @@ -46,4 +46,6 @@ public interface FlatteningWrapper { void forceLoadChunk(World world, int cX, int cZ); boolean checkPistonMoving(Block block); + + boolean isFacingWater(Block dispenser); }