mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 00:47:42 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@1e035f3 Only attempt to find spawn position if there isn't a fixed spawn position set (#11682) PaperMC/Paper@0f90942 Fix non-null initialisation of context collision shape PaperMC/Paper@4bc80b8 Do not break when PlayerNaturallySpawnCreaturesEvent is cancelled PaperMC/Paper@ae80a25 Properly handle large values of spawnChunkRadius PaperMC/Paper@c2294d7 Fix several off-by-one errors in view distance calculations PaperMC/Paper@da71382 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11702)
173 lines
10 KiB
Diff
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 c5644d8d64f12073e39bc6ed79c8714f4560ff89..47a2cba0db36b11548d06ec21f7c7d7c9a962d6e 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
|
@@ -263,6 +263,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 b1c917d65076a3805e5b78cb946753f0c101e214..82210667376fd466d5d4cdcb56b62f6165bd5cde 100644
|
|
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
|
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
|
@@ -409,6 +409,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 {
|
|
@@ -418,7 +419,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 f6ad220e3e228e978c8b635064e8d5bf65ac5a89..67db7d9f57fd4407412b9cfbc8b0ab06f15fff12 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1270,7 +1270,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 2a7fd4420467cce0c4ddca749955ba45e034e555..c142f25e520e69d343702fcd83dfbbb117370d69 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
|
|
gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish
|
|
gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish
|
|
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)));
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|