From 6ea17557eac9c457e1bef9a757f91e71dd1b8672 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 17 Feb 2023 10:56:46 +0100 Subject: [PATCH] Change extend area downwards Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/ArenaMode.java | 1 + .../src/de/steamwar/fightsystem/Config.java | 6 ++--- .../de/steamwar/fightsystem/FightSystem.java | 7 +++++- .../fightsystem/FightSystem.properties | 1 + .../fightsystem/FightSystem_de.properties | 1 + .../fightsystem/listener/PistonListener.java | 22 +++++++++++++------ .../fightsystem/listener/TeamArea.java | 2 +- .../de/steamwar/fightsystem/utils/Region.java | 6 ++--- 8 files changed, 31 insertions(+), 15 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java index 62dd249..ad4e2a3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java @@ -43,6 +43,7 @@ public enum ArenaMode { public static final Set AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY))); public static final Set AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK))); public static final Set AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT))); + public static final Set AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE))); public static final Set AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE))); public static final Set VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY))); public static final Set RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY)); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java index f1affb4..00ea877 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -305,9 +305,9 @@ public class Config { RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ); BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ); - RedExtendRegion = new Region(teamRedCornerX, underBorder, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea); - BlueExtendRegion = new Region(blueCornerX, underBorder, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea); - ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ); + RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); + BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, arenaYSize, schemsizeZ, PreperationArea, PreperationArea, PreperationArea); + ArenaRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, arenaYSize, arenaMaxZ - arenaMinZ); //TODO adjust ArenaRegion? EventKampfID = Integer.parseInt(System.getProperty("fightID", "0")); if(EventKampfID >= 1){ diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 8c2b5a0..e5cc1ba 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -67,7 +67,12 @@ public class FightSystem extends JavaPlugin { new EntityDamage(); new WaterRemover(); new Permanent(); - new PistonListener(); + new PistonListener(ArenaMode.AntiTestCheckPrepare, e -> e.setCancelled(true)); + new PistonListener(ArenaMode.Test, e -> getMessage().broadcastActionbar("PISTON_PUSHED_OUTSIDE")); + new PistonListener(ArenaMode.Prepare, e -> { + getMessage().broadcast("PISTON_PUSHED_OUTSIDE"); + shutdown(); + }); new Chat(); new ArenaBorder(); new TeamArea(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index ef060ac..7a0114a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -156,6 +156,7 @@ PREPARE_SENT_IN=§aA team member will review the schematic soon PARTICIPANT_CHAT={0} {1}§8» §7{2} FIGHTLEADER_CHAT=§e{0}§8» §e{1} SPECTATOR_CHAT=§7{0}§8» §7{1} +PISTON_PUSHED_OUTSIDE=§cA piston pushed a block outside the allowed area! # Replay diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties index 2809513..fff7bc4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -150,6 +150,7 @@ PREPARE_SCHEM_EXISTS=§cEs existiert bereits eine Schem mit Namenszusatz -prepar PREPARE_ACTIVE_PISTON=§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen. PREPARE_FAILED_SAVING=§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen. PREPARE_SENT_IN=§aDie Schematic wird nun zeitnah von einem Teammitglied überprüft +PISTON_PUSHED_OUTSIDE=§cEin Kolben hat einen Block aus dem erlaubten Bereich geschoben! # Replay diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java index 7aba189..26c2fb8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java @@ -28,17 +28,25 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.PistonMoveReaction; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPistonEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; +import java.util.Set; +import java.util.function.Consumer; + public class PistonListener implements Listener { - public PistonListener() { + private final Consumer leftAreaHandler; + + public PistonListener(Set condition, Consumer leftAreaHandler) { + this.leftAreaHandler = leftAreaHandler; + if(!condition.contains(Config.mode)) + return; + //Wenn Entern aktiv ist, sollen Raketen etc. entern können - if(!ArenaMode.Check.contains(Config.mode)) { - new StateDependentListener(!Config.AllowMissiles, FightState.All, this); - new StateDependentListener(Config.AllowMissiles, FightState.Setup, this); - } + new StateDependentListener(!Config.AllowMissiles, FightState.All, this); + new StateDependentListener(Config.AllowMissiles, FightState.Setup, this); } @EventHandler @@ -50,7 +58,7 @@ public class PistonListener implements Listener { for(Block block : e.getBlocks()){ Block target = block.getRelative(face); if(!Config.BlueExtendRegion.inRegion(target) && !Config.RedExtendRegion.inRegion(target) && block.getPistonMoveReaction() != PistonMoveReaction.BREAK) { - e.setCancelled(true); + leftAreaHandler.accept(e); return; } } @@ -63,7 +71,7 @@ public class PistonListener implements Listener { for(Block block : e.getBlocks()){ if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)) { - e.setCancelled(true); + leftAreaHandler.accept(e); return; } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index 44aef93..e091c92 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -80,7 +80,7 @@ public class TeamArea implements Listener { @EventHandler public void blockBreak(BlockBreakEvent event) { Block block = event.getBlock(); - if(Config.BluePasteRegion.getMinY() <= block.getY()) + if(Config.BlueExtendRegion.getMinY() <= block.getY()) return; event.setCancelled(true); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java index ac6d9a3..9e547c8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java @@ -33,9 +33,9 @@ public class Region { private final int maxY; private final int maxZ; - public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendZ) { - this(minX - extendX, minY, minZ - extendZ, - sizeX + extendX * 2, sizeY, sizeZ + extendZ * 2); + public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) { + this(minX - extendX, minY - extendY, minZ - extendZ, + sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2); } public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {