mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-29 11:49:07 +00:00
Rename allow-non-tnt-breaking-durable-blocks
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.Set;
|
||||
public final class WorldConfiguration extends ConfigurationPart {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
static final int CURRENT_VERSION = 8; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
|
||||
static final int CURRENT_VERSION = 9; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
|
||||
|
||||
private transient final ResourceLocation worldKey;
|
||||
WorldConfiguration(ResourceLocation worldKey) {
|
||||
@@ -83,16 +83,18 @@ public final class WorldConfiguration extends ConfigurationPart {
|
||||
|
||||
public Explosion explosion = new Explosion();
|
||||
public class Explosion extends ConfigurationPart {
|
||||
public boolean optimiseProtectedRegions = false;
|
||||
public boolean avoidRedundantBlockSearches = false;
|
||||
public Map<Block, DurableMaterial> durableMaterials = Util.make(new Reference2ObjectOpenHashMap<>(), map -> {
|
||||
map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance()));
|
||||
map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
||||
map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
||||
map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
||||
});
|
||||
@Comment("When disabled all explosions will be able to damage durable materials.")
|
||||
public boolean requireTntToDamageDurableMaterials = true;
|
||||
|
||||
public boolean optimiseProtectedRegions = false;
|
||||
public boolean avoidRedundantBlockSearches = false;
|
||||
public boolean protectScaffoldingFromCreepers = false;
|
||||
public boolean allowNonTntBreakingDurableBlocks = false;
|
||||
public boolean destroyWaterloggedBlocks = false;
|
||||
public boolean explodeLava = false;
|
||||
public boolean consistentRadius = false;
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
import org.spongepowered.configurate.transformation.TransformAction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class ConfigurationTransformations {
|
||||
private static final List<NodePath> REMOVED_GLOBAL_PATHS = List.of(
|
||||
@@ -26,6 +27,7 @@ public final class ConfigurationTransformations {
|
||||
V6_FixIncorrectExtraKnockback.apply(versionedBuilder);
|
||||
V7_FixTntDuplicationName.apply(versionedBuilder);
|
||||
V8_RenameExplosionResistantItems.apply(versionedBuilder);
|
||||
V9_RenameAllowNonTntBreakingDurableBlocks.apply(versionedBuilder);
|
||||
// ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
|
||||
versionedBuilder.build().apply(node);
|
||||
}
|
||||
@@ -44,5 +46,21 @@ public final class ConfigurationTransformations {
|
||||
versionedBuilder.build().apply(node);
|
||||
}
|
||||
|
||||
public static TransformAction newValue(final Function<ConfigurationNode, Object> func) {
|
||||
return (k, v) -> {
|
||||
if (!v.virtual()) {
|
||||
Object val = func.apply(v);
|
||||
if (val != null) {
|
||||
v.raw(val);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static TransformAction move(final NodePath path) {
|
||||
return (p, n) -> path.array();
|
||||
}
|
||||
|
||||
private ConfigurationTransformations() {}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ public final class V2_VerticalKnockbackUseDefault implements TransformAction {
|
||||
private V2_VerticalKnockbackUseDefault() {}
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(PATH, INSTANCE)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,9 @@ public final class V4_RenameNonStrictMergeLevel implements TransformAction {
|
||||
private V4_RenameNonStrictMergeLevel() {}
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(PATH, INSTANCE)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,9 @@ public final class V5_CombineLoadChunksOptions implements TransformAction {
|
||||
private V5_CombineLoadChunksOptions() {}
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(PATH, INSTANCE)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,9 @@ public final class V6_FixIncorrectExtraKnockback implements TransformAction {
|
||||
private V6_FixIncorrectExtraKnockback() {}
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(PATH, INSTANCE)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,14 +2,18 @@ package me.samsuik.sakura.configuration.transformation.world;
|
||||
|
||||
import org.spongepowered.configurate.NodePath;
|
||||
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
import org.spongepowered.configurate.transformation.TransformAction;
|
||||
|
||||
import static org.spongepowered.configurate.NodePath.*;
|
||||
import static org.spongepowered.configurate.transformation.TransformAction.rename;
|
||||
|
||||
public final class V7_FixTntDuplicationName {
|
||||
private static final int VERSION = 7;
|
||||
private static final NodePath OLD_PATH = NodePath.path("technical", "allow-t-n-t-duplication");
|
||||
private static final NodePath OLD_PATH = path("technical", "allow-t-n-t-duplication");
|
||||
private static final String NEW_NAME = "allow-tnt-duplication";
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(OLD_PATH, TransformAction.rename(NEW_NAME)).build());
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(OLD_PATH, rename(NEW_NAME))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package me.samsuik.sakura.configuration.transformation.world;
|
||||
|
||||
import org.spongepowered.configurate.NodePath;
|
||||
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
import org.spongepowered.configurate.transformation.TransformAction;
|
||||
|
||||
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.move;
|
||||
import static org.spongepowered.configurate.NodePath.path;
|
||||
|
||||
public final class V8_RenameExplosionResistantItems {
|
||||
@@ -20,8 +20,4 @@ public final class V8_RenameExplosionResistantItems {
|
||||
.addAction(OLD_ITEMS_PATH, move(NEW_ITEMS_PATH))
|
||||
.build());
|
||||
}
|
||||
|
||||
private static TransformAction move(NodePath path) {
|
||||
return (p, n) -> path.array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.samsuik.sakura.configuration.transformation.world;
|
||||
|
||||
import org.spongepowered.configurate.NodePath;
|
||||
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
|
||||
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.move;
|
||||
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.newValue;
|
||||
import static org.spongepowered.configurate.NodePath.*;
|
||||
|
||||
public final class V9_RenameAllowNonTntBreakingDurableBlocks {
|
||||
private static final int VERSION = 9;
|
||||
private static final NodePath PARENT = path("cannons", "explosion");
|
||||
private static final NodePath OLD_PATH = PARENT.plus(path("allow-non-tnt-breaking-durable-blocks"));
|
||||
private static final NodePath NEW_PATH = PARENT.plus(path("require-tnt-to-damage-durable-materials"));
|
||||
|
||||
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(OLD_PATH, move(NEW_PATH))
|
||||
.addAction(NEW_PATH, newValue(v -> !v.getBoolean()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user