forked from SteamWar/SteamWar
Merge pull request 'add setting to disable block generators' (#375) from Jaki/SteamWar:main into main
Reviewed-on: SteamWar/SteamWar#375 Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
This commit is contained in:
@@ -411,7 +411,7 @@ public final class GameModeConfig<M, W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
public static final class ArenaConfig {
|
public static final class ArenaConfig<M, W> {
|
||||||
|
|
||||||
public final boolean loaded;
|
public final boolean loaded;
|
||||||
|
|
||||||
@@ -461,11 +461,11 @@ public final class GameModeConfig<M, W> {
|
|||||||
public final boolean DisableSnowMelt;
|
public final boolean DisableSnowMelt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable ice forming
|
* Disable the forming of certain blocks
|
||||||
*
|
*
|
||||||
* @implSpec {@code false} by default
|
* @implSpec {@code empty} by default
|
||||||
*/
|
*/
|
||||||
public final boolean DisableIceForm;
|
public final Set<M> DisabledBlockForms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow leaving the arena area as spectator
|
* Allow leaving the arena area as spectator
|
||||||
@@ -488,7 +488,7 @@ public final class GameModeConfig<M, W> {
|
|||||||
*/
|
*/
|
||||||
public final boolean NoFloor;
|
public final boolean NoFloor;
|
||||||
|
|
||||||
private ArenaConfig(YMLWrapper loader, SchematicConfig.SizeConfig Size, List<Integer> EnterStages) {
|
private ArenaConfig(YMLWrapper<M, W> loader, SchematicConfig.SizeConfig Size, List<Integer> EnterStages) {
|
||||||
loaded = loader.canLoad();
|
loaded = loader.canLoad();
|
||||||
WaterDepth = loader.getInt("WaterDepth", 0);
|
WaterDepth = loader.getInt("WaterDepth", 0);
|
||||||
WaterDamage = loader.getBoolean("WaterDamage", true);
|
WaterDamage = loader.getBoolean("WaterDamage", true);
|
||||||
@@ -497,7 +497,11 @@ public final class GameModeConfig<M, W> {
|
|||||||
BorderFromSchematic = loader.getInt("BorderFromSchematic", 21);
|
BorderFromSchematic = loader.getInt("BorderFromSchematic", 21);
|
||||||
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);
|
Set<M> disabledBlockForms = new HashSet<>(loader.getMaterialList("DisabledBlockForms"));
|
||||||
|
if (loader.getBoolean("DisableIceForm", false)) {
|
||||||
|
disabledBlockForms.add(loader.materialMapper.apply("ICE"));
|
||||||
|
}
|
||||||
|
DisabledBlockForms = Collections.unmodifiableSet(disabledBlockForms);
|
||||||
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,16 @@ 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
|
||||||
|
# Disabled blocks from forming
|
||||||
|
DisabledBlockForms:
|
||||||
|
# For Cobble Generators
|
||||||
|
# - COBBLESTONE
|
||||||
|
# - BASALT
|
||||||
|
# - STONE
|
||||||
|
# - OBSIDIAN
|
||||||
|
# Disable ice specifically from forming
|
||||||
|
# Deprecated, add ICE to DisabledBlockForms list instead
|
||||||
|
DisableIceForm: false
|
||||||
# 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.
|
||||||
|
|||||||
+6
-2
@@ -32,12 +32,16 @@ import org.bukkit.event.block.BlockFormEvent;
|
|||||||
public class BlockFormListener implements Listener {
|
public class BlockFormListener implements Listener {
|
||||||
|
|
||||||
public BlockFormListener() {
|
public BlockFormListener() {
|
||||||
new StateDependentListener(Config.GameModeConfig.Arena.DisableIceForm, FightState.All, this);
|
boolean enabled = !Config.GameModeConfig.Arena.DisabledBlockForms.isEmpty();
|
||||||
|
new StateDependentListener(enabled, FightState.All, 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.DisabledBlockForms.contains(material)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user