forked from SteamWar/SteamWar
add setting to disable block generators
This commit is contained in:
@@ -467,6 +467,13 @@ public final class GameModeConfig<M, W> {
|
||||
*/
|
||||
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<M, W> {
|
||||
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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
+22
-2
@@ -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<Material> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user