forked from SteamWar/SteamWar
migrate to per material config
This commit is contained in:
@@ -48,10 +48,13 @@ 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
|
||||
# Disabled blocks from forming
|
||||
BlockedFormedBlocks:
|
||||
# For Cobble Generators
|
||||
# - COBBLESTONE
|
||||
# - BASALT
|
||||
# - STONE
|
||||
# - OBSIDIAN
|
||||
# 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.
|
||||
|
||||
+3
-19
@@ -27,25 +27,13 @@ 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() {
|
||||
boolean enabled = Config.GameModeConfig.Arena.DisableIceForm
|
||||
|| Config.GameModeConfig.Arena.DisableBlockGenerators;
|
||||
new StateDependentListener(enabled,
|
||||
Config.GameModeConfig.Arena.DisableIceForm ? FightState.All : FightState.Running,
|
||||
this);
|
||||
boolean enabled = !Config.GameModeConfig.Arena.BlockedFormedBlocks.isEmpty();
|
||||
new StateDependentListener(enabled, FightState.All, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -53,11 +41,7 @@ public class BlockFormListener implements Listener {
|
||||
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)) {
|
||||
if (Config.GameModeConfig.Arena.BlockedFormedBlocks.contains(material)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user