add setting to disable block generators

This commit is contained in:
Jakob Schulz
2026-05-18 21:26:38 +02:00
parent 6da180136e
commit 706f6ed743
3 changed files with 34 additions and 2 deletions
@@ -467,6 +467,13 @@ public final class GameModeConfig<M, W> {
*/ */
public final boolean DisableIceForm; 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 * Allow leaving the arena area as spectator
* *
@@ -498,6 +505,7 @@ public final class GameModeConfig<M, W> {
GroundWalkable = loader.getBoolean("GroundWalkable", true); GroundWalkable = loader.getBoolean("GroundWalkable", true);
DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false); DisableSnowMelt = loader.getBoolean("DisableSnowMelt", false);
DisableIceForm = loader.getBoolean("DisableIceForm", false); DisableIceForm = loader.getBoolean("DisableIceForm", false);
DisableBlockGenerators = loader.getBoolean("DisableBlockGenerators", false);
Leaveable = loader.getBoolean("Leaveable", false); Leaveable = loader.getBoolean("Leaveable", false);
AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty()); AllowMissiles = loader.getBoolean("AllowMissiles", !EnterStages.isEmpty());
NoFloor = loader.getBoolean("NoFloor", false); NoFloor = loader.getBoolean("NoFloor", false);
@@ -48,6 +48,10 @@ Arena:
GroundWalkable: true # defaults to true if missing GroundWalkable: true # defaults to true if missing
# Disable snow and ice melting # Disable snow and ice melting
DisableSnowMelt: false # defaults to false if missing 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 # Allow leaving the arena area as spectator
Leaveable: false # defaults to false if missing Leaveable: false # defaults to false if missing
# Allow missiles to fly to the enemy and not stop at the schem border. # Allow missiles to fly to the enemy and not stop at the schem border.
@@ -27,17 +27,37 @@ import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFormEvent;
import java.util.EnumSet;
import java.util.Set;
@Linked @Linked
public class BlockFormListener implements Listener { public class BlockFormListener implements Listener {
private static final Set<Material> GENERATOR_BLOCKS = EnumSet.of(
Material.COBBLESTONE,
Material.STONE,
Material.OBSIDIAN,
Material.BASALT
);
public BlockFormListener() { 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 @EventHandler
public void onBlockForm(BlockFormEvent event) { 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); event.setCancelled(true);
} }
} }