diff --git a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java index e2106380..fdebfb6b 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java +++ b/CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java @@ -467,6 +467,13 @@ public final class GameModeConfig { */ public final boolean DisableIceForm; + /** + * Disable block generators such as cobblestone, stone, obsidian and basalt + * + * @implSpec {@code false} by default + */ + public final boolean DisableBlockGenerators; + /** * Allow leaving the arena area as spectator * @@ -498,6 +505,7 @@ public final class GameModeConfig { GroundWalkable = loader.getBoolean("GroundWalkable", true); DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false); DisableIceForm = loader.getBoolean("DisableIceForm", false); + DisableBlockGenerators = loader.getBoolean("DisableBlockGenerators", false); Leaveable = loader.getBoolean("Leaveable", false); AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty()); NoFloor = loader.getBoolean("NoFloor", false); diff --git a/FightSystem/FightSystem_Core/src/config.yml b/FightSystem/FightSystem_Core/src/config.yml index 46267a72..0d700de5 100644 --- a/FightSystem/FightSystem_Core/src/config.yml +++ b/FightSystem/FightSystem_Core/src/config.yml @@ -48,6 +48,10 @@ Arena: GroundWalkable: true # defaults to true if missing # Disable snow and ice melting DisableSnowMelt: false # defaults to false if missing + # Disable ice forming + DisableIceForm: false # defaults to false if missing + # Disable cobblestone, stone, obsidian and basalt generators + DisableBlockGenerators: false # defaults to false if missing # Allow leaving the arena area as spectator Leaveable: false # defaults to false if missing # Allow missiles to fly to the enemy and not stop at the schem border. diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFormListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFormListener.java index 29c6be82..275fc4c4 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFormListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/BlockFormListener.java @@ -27,17 +27,37 @@ import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockFormEvent; +import java.util.EnumSet; +import java.util.Set; @Linked public class BlockFormListener implements Listener { + private static final Set GENERATOR_BLOCKS = EnumSet.of( + Material.COBBLESTONE, + Material.STONE, + Material.OBSIDIAN, + Material.BASALT + ); + public BlockFormListener() { - new StateDependentListener(Config.GameModeConfig.Arena.DisableIceForm, FightState.All, this); + boolean enabled = Config.GameModeConfig.Arena.DisableIceForm + || Config.GameModeConfig.Arena.DisableBlockGenerators; + new StateDependentListener(enabled, + Config.GameModeConfig.Arena.DisableIceForm ? FightState.All : FightState.Running, + this); } @EventHandler public void onBlockForm(BlockFormEvent event) { - if (Config.ArenaRegion.inRegion(event.getBlock()) && event.getNewState().getType() == Material.ICE) { + if (!Config.ArenaRegion.inRegion(event.getBlock())) return; + + Material material = event.getNewState().getType(); + if (Config.GameModeConfig.Arena.DisableIceForm && material == Material.ICE) { + event.setCancelled(true); + } else if (Config.GameModeConfig.Arena.DisableBlockGenerators + && FightState.infight() + && GENERATOR_BLOCKS.contains(material)) { event.setCancelled(true); } }