diff --git a/api/src/main/java/org/screamingsandals/bedwars/api/config/GameConfigurationContainer.java b/api/src/main/java/org/screamingsandals/bedwars/api/config/GameConfigurationContainer.java index f00a49c67..06f683766 100644 --- a/api/src/main/java/org/screamingsandals/bedwars/api/config/GameConfigurationContainer.java +++ b/api/src/main/java/org/screamingsandals/bedwars/api/config/GameConfigurationContainer.java @@ -135,4 +135,7 @@ public interface GameConfigurationContainer extends ConfigurationContainer { ConfigurationKey KICK_PLAYERS_UPON_FINAL_DEATH_ENABLED = ConfigurationKey.of(Boolean.class, "kick-players-upon-final-death", "enabled"); ConfigurationKey KICK_PLAYERS_UPON_FINAL_DEATH_DELAY = ConfigurationKey.of(Integer.class, "kick-players-upon-final-death", "delay"); + + ConfigurationKey DESTROY_PLACED_BLOCKS_BY_EXPLOSION_ENABLED = ConfigurationKey.of(Boolean.class, "destroy-placed-blocks-by-explosion", "enabled"); + ConfigurationListKey DESTROY_PLACED_BLOCKS_BY_EXPLOSION_BLACKLIST = ConfigurationListKey.of(String.class, "destroy-placed-blocks-by-explosion", "blacklist"); // Block predicates (block state, #tag or type[*]) } diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/GameConfigurationContainerImpl.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/GameConfigurationContainerImpl.java index 1ff07e121..6ea495224 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/GameConfigurationContainerImpl.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/GameConfigurationContainerImpl.java @@ -134,6 +134,8 @@ public class GameConfigurationContainerImpl extends ConfigurationContainerImpl i register(STATISTICS_SCORES_RECORD, "statistics", "scores", "record"); register(KICK_PLAYERS_UPON_FINAL_DEATH_ENABLED, "kick-players-upon-final-death", "enabled"); register(KICK_PLAYERS_UPON_FINAL_DEATH_ENABLED, "kick-players-upon-final-death", "delay"); + register(DESTROY_PLACED_BLOCKS_BY_EXPLOSION_ENABLED, "destroy-placed-blocks-by-explosion", "enabled"); + register(DESTROY_PLACED_BLOCKS_BY_EXPLOSION_BLACKLIST, "destroy-placed-blocks-by-explosion", "blacklist"); } protected void migrateOld(ConfigurationNode configurationNode) { diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java index 4790015f1..1e7c77710 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java @@ -125,21 +125,25 @@ public void load() { .key("disable-hunger").defValue(false) .key("automatic-coloring-in-shop").defValue(true) .key("sell-max-64-per-click-in-shop").defValue(true) - .key("destroy-placed-blocks-by-explosion-except") - .remapWhen(node -> !node.empty() && !node.isList()) - .remap(node -> { - if (!node.empty() && !node.isList()) { - var str = node.getString(); - try { - var data = str == null ? List.of() : List.of(str); - node.set(data); - } catch(SerializationException ex) { - ex.printStackTrace(); - } - } - }) - .defValue(List::of) - .key("destroy-placed-blocks-by-explosion").defValue(true) + .key("destroy-placed-blocks-by-explosion").moveIfAbsolute(n -> !n.virtual() && !n.isMap(), "destroy-placed-blocks-by-explosion", "enabled") + .section("destroy-placed-blocks-by-explosion") + .key("enabled").defValue(true) + .key("blacklist") + .migrateOldAbsoluteKey("destroy-placed-blocks-by-explosion-except") + .remapWhen(node -> !node.empty() && !node.isList()) + .remap(node -> { + if (!node.empty() && !node.isList()) { + var str = node.getString(); + try { + var data = str == null ? List.of() : List.of(str); + node.set(data); + } catch(SerializationException ex) { + ex.printStackTrace(); + } + } + }) + .defValue(List::of) + .back() .key("holograms-above-bed").migrateOld("holo-above-bed").defValue(true) .key("allow-spectator-join").defValue(false) .section("disable-server-message") diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/WorldListener.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/WorldListener.java index aa1a54581..4fb5e5da8 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/WorldListener.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/WorldListener.java @@ -46,6 +46,7 @@ import org.spongepowered.configurate.ConfigurationNode; import java.util.Collection; +import java.util.List; import java.util.Objects; @Service @@ -147,13 +148,13 @@ public void onExplode(BlockExplodeEvent event) { } public void onExplode(Location location, Collection blockList, org.screamingsandals.lib.event.Cancellable cancellable, boolean originatedInArena) { - final var explosionExceptionTypeName = MainConfig.getInstance().node("destroy-placed-blocks-by-explosion-except").childrenList().stream().map(ConfigurationNode::getString).toArray(); - final var destroyPlacedBlocksByExplosion = MainConfig.getInstance().node("destroy-placed-blocks-by-explosion").getBoolean(true); final var breakableExplosions = MainConfig.getInstance().node("breakable", "explosions").getBoolean(true); for (var game : GameManagerImpl.getInstance().getGames()) { if (ArenaUtils.isInArea(location, game.getPos1(), game.getPos2())) { if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) { + final var destroyPlacedBlocksByExplosion = game.getConfigurationContainer().getOrDefault(GameConfigurationContainer.DESTROY_PLACED_BLOCKS_BY_EXPLOSION_ENABLED, true); + final var explosionExceptionTypeName = game.getConfigurationContainer().getOrDefault(GameConfigurationContainer.DESTROY_PLACED_BLOCKS_BY_EXPLOSION_BLACKLIST, List.of()).toArray(); blockList.removeIf(block -> { if (!game.isBlockAddedDuringGame(block.location())) { if (game.getConfigurationContainer().getOrDefault(GameConfigurationContainer.TARGET_BLOCK_ALLOW_DESTROYING_WITH_EXPLOSIONS, false)) { diff --git a/plugin/common/src/main/resources/variants/certain-popular-server.yml b/plugin/common/src/main/resources/variants/certain-popular-server.yml index 4076cbf0e..4e1da0012 100644 --- a/plugin/common/src/main/resources/variants/certain-popular-server.yml +++ b/plugin/common/src/main/resources/variants/certain-popular-server.yml @@ -81,14 +81,17 @@ config: game-start-items: enabled: true items: - - WOODEN_SWORD - - LEATHER_HELMET - - LEATHER_CHESTPLATE - - LEATHER_LEGGINGS - - LEATHER_BOOTS + - wooden_sword + - leather_helmet + - leather_chestplate + - leather_leggings + - leather_boots + destroy-placed-blocks-by-explosion: + enabled: true + blacklist: + - glass -# TODO: custom destroy-placed-blocks-by-explosion-except > GLASS # TODO: breakable blocks (GRASS, LONG_GRASS, SNOW) # TODO: just add every missing configuration @@ -96,28 +99,28 @@ default-spawner-types-included: false custom-spawner-types: emerald: spread: 0.1 - material: EMERALD + material: emerald translate: resource_emerald interval: 60 color: GREEN name: Emerald diamond: spread: 0.1 - material: DIAMOND + material: diamond translate: resource_diamond interval: 30 color: BLUE name: Diamond iron: spread: 0.1 - material: IRON_INGOT + material: iron_ingot translate: resource_iron interval: 2 # interval is currently still int btw, default value in SBA: 2.5 color: WHITE name: Iron gold: spread: 0.1 - material: GOLD_INGOT + material: gold_ingot translate: resource_gold interval: 8 color: GOLD