Files
Purpur/patches/server/0051-Configurable-void-damage-height-and-damage.patch
granny 89e388c3a2 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@bcf52fe Delete some old patches
PaperMC/Paper@348c855 Readd last API patch (with TODO)
PaperMC/Paper@b630564 More patches
PaperMC/Paper@3cb16c9 Add back per player mob spawning
PaperMC/Paper@fe7b741 Another one
PaperMC/Paper@12ed021 Update material tags and entity effect
PaperMC/Paper@02bca1e Remove timings impl
PaperMC/Paper@4d87302 Fix NPE and StackOverflowError for dispensers
PaperMC/Paper@f8f230a Remove unnecessary AT
PaperMC/Paper@29bf7be Fix unused parameter in PlayerList#remove
PaperMC/Paper@9e35192 Execute spark tasks during tick sleep (#11525)
PaperMC/Paper@e35f199 Use declaration order for state holder property iteration
PaperMC/Paper@6288adb Remove leftover missed timings calls (#11527)
2024-10-28 00:16:09 -07:00

173 lines
10 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Thu, 27 Feb 2020 21:42:19 -0600
Subject: [PATCH] Configurable void damage height and damage
temporarily migrate to paper's config
drop patch on the next minecraft release
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index 1029b6de6f36b08bf634b4056ef5701383f6f258..ee0d1df78838e05450ad1a06ce70eab2d5e5d3b8 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -260,6 +260,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
for (final NodePath path : RemovedConfigurations.REMOVED_WORLD_PATHS) {
builder.addAction(path, TransformAction.remove());
}
+ org.purpurmc.purpur.configuration.transformation.VoidDamageHeightMigration.apply(builder, contextMap); // Purpur
builder.build().apply(node);
final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder();
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
index a81a332ffb80e67d7f886295099b5cd2ae8994c5..1d18cad6c32815854ff8dace256b59022200c842 100644
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -400,6 +400,7 @@ public class WorldConfiguration extends ConfigurationPart {
public boolean useVanillaWorldScoreboardNameColoring = false;
}
+ @Setting(org.purpurmc.purpur.configuration.transformation.VoidDamageHeightMigration.ENVIRONMENT_KEY) // Purpur
public Environment environment;
public class Environment extends ConfigurationPart {
@@ -409,7 +410,9 @@ public class WorldConfiguration extends ConfigurationPart {
public boolean disableExplosionKnockback = false;
public boolean generateFlatBedrock = false;
public FrostedIce frostedIce;
+ @Setting(org.purpurmc.purpur.configuration.transformation.VoidDamageHeightMigration.VOID_DAMAGE_KEY) // Purpur
public DoubleOr.Disabled voidDamageAmount = new DoubleOr.Disabled(OptionalDouble.of(4));
+ @Setting(org.purpurmc.purpur.configuration.transformation.VoidDamageHeightMigration.VOID_DAMAGE_MIN_HEIGHT_OFFSET_KEY) // Purpur
public double voidDamageMinBuildHeightOffset = -64.0;
public class FrostedIce extends ConfigurationPart {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a1ba1896963ab0127de00f5906351872760e5439..5b917da2009c31f62a21b3064c865dc181986843 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1268,7 +1268,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
LOGGER.info("*************************************************************************************");
}
// Paper end - Add onboarding message for initial server start
-
+ // Purpur start
+ if (org.purpurmc.purpur.configuration.transformation.VoidDamageHeightMigration.HAS_BEEN_REGISTERED) {
+ try {
+ org.purpurmc.purpur.PurpurConfig.config.save((File) this.options.valueOf("purpur-settings"));
+ } catch (IOException ex) {
+ Bukkit.getLogger().log(java.util.logging.Level.SEVERE, "Could not save " + this.options.valueOf("purpur-settings"), ex);
+ }
+ }
+ // Purpur end
while (this.running) {
long i;
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index c4d6ffd9b1afee8405914bda5834bb3e7d909811..de6f842349dee273eb84b2f12ea6a41d43f17fb1 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -219,6 +219,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
org.spigotmc.SpigotConfig.registerCommands();
// Spigot end
io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc.
+ // Purpur start
+ try {
+ org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings"));
+ } catch (Exception e) {
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
+ return false;
+ }
+ org.purpurmc.purpur.PurpurConfig.registerCommands();
+ // Purpur end
// Paper start - initialize global and world-defaults configuration
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
@@ -235,15 +244,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
- // Purpur start
- try {
- org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings"));
- } catch (Exception e) {
- DedicatedServer.LOGGER.error("Unable to load server configuration", e);
- return false;
- }
- org.purpurmc.purpur.PurpurConfig.registerCommands();
- // Purpur end
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
this.setPvpAllowed(dedicatedserverproperties.pvp);
diff --git a/src/main/java/org/purpurmc/purpur/configuration/transformation/VoidDamageHeightMigration.java b/src/main/java/org/purpurmc/purpur/configuration/transformation/VoidDamageHeightMigration.java
new file mode 100644
index 0000000000000000000000000000000000000000..a04d23bd98075cd65a24d4de8d18281d1668480f
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/configuration/transformation/VoidDamageHeightMigration.java
@@ -0,0 +1,67 @@
+package org.purpurmc.purpur.configuration.transformation;
+
+import io.papermc.paper.configuration.Configurations;
+import io.papermc.paper.configuration.PaperConfigurations;
+import io.papermc.paper.configuration.type.number.DoubleOr;
+import java.util.OptionalDouble;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.purpurmc.purpur.PurpurConfig;
+import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.ConfigurationNode;
+import org.spongepowered.configurate.NodePath;
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
+import org.spongepowered.configurate.transformation.TransformAction;
+
+import static org.spongepowered.configurate.NodePath.path;
+
+public class VoidDamageHeightMigration implements TransformAction {
+
+ public static boolean HAS_BEEN_REGISTERED = false;
+
+ public static final String ENVIRONMENT_KEY = "environment";
+ public static final String VOID_DAMAGE_KEY = "void-damage-amount";
+ public static final String VOID_DAMAGE_MIN_HEIGHT_OFFSET_KEY = "void-damage-min-build-height-offset";
+ public static final double DEFAULT_VOID_DAMAGE_HEIGHT = -64.0D;
+ public static final double DEFAULT_VOID_DAMAGE = 4.0D;
+
+ private final String worldName;
+
+ private VoidDamageHeightMigration(String worldName) {
+ this.worldName = PaperConfigurations.WORLD_DEFAULTS.equals(worldName) ? "default" : worldName;
+ }
+
+ @Override
+ public Object @Nullable [] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException {
+ String purpurVoidDamageHeightPath = "world-settings." + this.worldName + ".gameplay-mechanics.void-damage-height";
+ ConfigurationNode voidDamageMinHeightOffsetNode = value.node(ENVIRONMENT_KEY, VOID_DAMAGE_MIN_HEIGHT_OFFSET_KEY);
+ if (PurpurConfig.config.contains(purpurVoidDamageHeightPath)) {
+ double purpurVoidDamageHeight = PurpurConfig.config.getDouble(purpurVoidDamageHeightPath);
+ if (purpurVoidDamageHeight != DEFAULT_VOID_DAMAGE_HEIGHT && (voidDamageMinHeightOffsetNode.empty() || voidDamageMinHeightOffsetNode.getDouble() == DEFAULT_VOID_DAMAGE_HEIGHT)) {
+ voidDamageMinHeightOffsetNode.raw(null);
+ voidDamageMinHeightOffsetNode.set(purpurVoidDamageHeight);
+ }
+ PurpurConfig.config.set(purpurVoidDamageHeightPath, null);
+ }
+
+ String purpurVoidDamagePath = "world-settings." + this.worldName + ".gameplay-mechanics.void-damage-dealt";
+ ConfigurationNode voidDamageNode = value.node(ENVIRONMENT_KEY, VOID_DAMAGE_KEY);
+ if (PurpurConfig.config.contains(purpurVoidDamagePath)) {
+ double purpurVoidDamage = PurpurConfig.config.getDouble(purpurVoidDamagePath);
+ if (purpurVoidDamage != DEFAULT_VOID_DAMAGE && (voidDamageNode.empty() || voidDamageNode.getDouble() == DEFAULT_VOID_DAMAGE)) {
+ voidDamageNode.raw(null);
+ voidDamageNode.set(new DoubleOr.Disabled(OptionalDouble.of(purpurVoidDamage)));
+ }
+ PurpurConfig.config.set(purpurVoidDamagePath, null);
+ }
+
+ return null;
+ }
+
+ public static void apply(final ConfigurationTransformation.Builder builder, final Configurations.ContextMap contextMap) {
+ if (PurpurConfig.version < 36) {
+ HAS_BEEN_REGISTERED = true;
+ builder.addAction(path(), new VoidDamageHeightMigration(contextMap.require(Configurations.WORLD_NAME)));
+ }
+ }
+
+}