diff --git a/patches/api/0005-Various-API-Tweaks.patch b/patches/api/0005-Various-API-Tweaks.patch deleted file mode 100644 index 9825504..0000000 --- a/patches/api/0005-Various-API-Tweaks.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Mon, 6 May 2024 20:43:37 +0900 -Subject: [PATCH] Various API Tweaks - - -diff --git a/src/main/java/com/destroystokyo/paper/MaterialTags.java b/src/main/java/com/destroystokyo/paper/MaterialTags.java -index 679f78e07a3a2de745fa237165d0a8db5e086f29..ac24a288fda957546e2832f375bd1c958db8852b 100644 ---- a/src/main/java/com/destroystokyo/paper/MaterialTags.java -+++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java -@@ -591,6 +591,15 @@ public class MaterialTags { - .add(material -> material.name().startsWith("DEEPSLATE_") && material.name().endsWith("_ORE")) - .ensureSize("DEEPSLATE_ORES", 8).lock(); - -+ // Plazma start - Various API Tweaks -+ /** -+ * Covers the variants of stone ores. -+ */ -+ public static final MaterialSetTag STONE_ORES = new MaterialSetTag(keyFor("stone_ores")) -+ .add(material -> !material.name().startsWith("DEEPSLATE_") && !material.name().startsWith("NETHER_") && material.name().endsWith("_ORE")) -+ .ensureSize("STONE_ORES", 8).lock(); -+ // Plazma end - Various API Tweaks -+ - /** - * Covers the variants of raw ore blocks. - */ diff --git a/patches/server/0014-Tweak-console-logging.patch b/patches/server/0014-Tweak-console-logging.patch deleted file mode 100644 index 27d6e1b..0000000 --- a/patches/server/0014-Tweak-console-logging.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sun, 5 Nov 2023 10:40:49 +0900 -Subject: [PATCH] Tweak console logging - - -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 14fd0ff2b4dc226f2890e538587226cdb60d37c2..32ebee3620b5ec1ff57b92a581fb2d7f5dfe17cf 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -194,16 +194,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); - } - -- // Paper start - detect running as root -- if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { -- DedicatedServer.LOGGER.warn("****************************"); -- DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); -- DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); -- DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); -- DedicatedServer.LOGGER.warn("****************************"); -- } -- // Paper end - detect running as root -- - DedicatedServer.LOGGER.info("Loading properties"); - DedicatedServerProperties dedicatedserverproperties = this.settings.getProperties(); - -@@ -235,6 +225,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.plazmaConfigurations.initializeGlobalConfiguration(this.registryAccess()); // Plazma - Configurable Plazma - this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Plazma - Configurable Plazma - // Paper end - initialize global and world-defaults configuration -+ // Paper start - detect running as root // Plazma - Tweak console logging (moved down) -+ if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { -+ DedicatedServer.LOGGER.warn("****************************"); -+ DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); -+ DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); -+ DedicatedServer.LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); -+ DedicatedServer.LOGGER.warn("****************************"); -+ } -+ // Paper end - detect running as root - this.server.spark.enableEarlyIfRequested(); // Paper - spark - // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save - if (this.convertOldUsers()) { -@@ -344,6 +343,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; - String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; - // Paper end - Add Velocity IP Forwarding Support -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.offlineWarnings && !(io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.onlineMode)) // Plazma - Tweak console logging - if (!this.usesAuthentication()) { - DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -357,7 +357,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - DedicatedServer.LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); - } - // Spigot end -- DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); -+ DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file or set \"console-logs.offline-warnings\" to \"false\" in the config/plazma-global.yml file."); // Plazma - Tweak console logging - } - - -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 5b1705794a8c3914cb11fdd35f75c8e0c128ecd0..459eea7dae68afdf7e1443f29f6f8d0c68668b74 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1426,6 +1426,7 @@ public abstract class PlayerList { - } - - public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public -+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix) return true; // Plazma - Tweak console logging - return message.hasSignature() && !message.hasExpiredServer(Instant.now()); - } - -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index e89534b6e2b91483d7eddfcb3441e9addf9bccc7..3a9fa2ac6dc5eaa153deb06a005be51c59786bbe 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -85,4 +85,14 @@ public class GlobalConfiguration extends ConfigurationPart { - - } - -+ -+ public ConsoleLogs consoleLogs; -+ public class ConsoleLogs extends ConfigurationPart { -+ -+ public boolean offlineWarnings = true; -+ public boolean rootUserWarnings = true; -+ public boolean notSecurePrefix = true; -+ -+ } -+ - } diff --git a/patches/server/0018-Apply-various-optimizations.patch b/patches/server/0018-Apply-various-optimizations.patch deleted file mode 100644 index 9934d7a..0000000 --- a/patches/server/0018-Apply-various-optimizations.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Wed, 27 Sep 2023 22:11:15 +0900 -Subject: [PATCH] Apply various optimizations - -[REFERENCE PATCHES] -Akarin - Swaps the predicate order of collision - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 305a569f8cd83f3c67a4d4377f2881d36961dacd..8001ae563ac06d8ba9fd1de0b4111a3c8241de8c 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2332,8 +2332,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - public void playerTouch(Player player) {} - - public void push(Entity entity) { -+ if (entity.noPhysics || this.noPhysics) return; // Plazma - Swaps the predicate order of collision - if (!this.isPassengerOfSameVehicle(entity)) { -- if (!entity.noPhysics && !this.noPhysics) { -+ //if (!entity.noPhysics && !this.noPhysics) { // Plazma - Swaps the predicate order of collision - if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant - double d0 = entity.getX() - this.getX(); - double d1 = entity.getZ() - this.getZ(); -@@ -2361,8 +2362,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - entity.push(d0, 0.0D, d1); - } - } -- -- } -+ //} // Plazma - Swaps the predicate order of collision - } - } - diff --git a/patches/server/0024-Skip-event-if-no-listeners.patch b/patches/server/0024-Skip-event-if-no-listeners.patch deleted file mode 100644 index d982627..0000000 --- a/patches/server/0024-Skip-event-if-no-listeners.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Mon, 4 Dec 2023 23:17:15 +0900 -Subject: [PATCH] Skip event if no listeners - - -diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..23594fb7eb4b2f33146592866608c2858ef23937 100644 ---- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -@@ -36,15 +36,16 @@ class PaperEventManager { - - // SimplePluginManager - public void callEvent(@NotNull Event event) { -+ // Plazma start - Skip event if no listeners -+ RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners(); -+ if (listeners.length == 0) return; -+ // Plazma end - if (event.isAsynchronous() && this.server.isPrimaryThread()) { - throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); - } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) { - throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); - } - -- HandlerList handlers = event.getHandlers(); -- RegisteredListener[] listeners = handlers.getRegisteredListeners(); -- - for (RegisteredListener registration : listeners) { - if (!registration.getPlugin().isEnabled()) { - continue; diff --git a/patches/server/0040-Cleanup-logs.patch b/patches/server/0040-Cleanup-logs.patch deleted file mode 100644 index 0a44f85..0000000 --- a/patches/server/0040-Cleanup-logs.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Thu, 31 Oct 2024 22:53:16 +0900 -Subject: [PATCH] Cleanup logs - - -diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml -index a056aa167887abef9e6d531a9edd2cda433567d2..dbd822604471e7405e350586ea0e294e0234cf06 100644 ---- a/src/main/resources/log4j2.xml -+++ b/src/main/resources/log4j2.xml -@@ -7,7 +7,7 @@ - - - -- - - -@@ -18,7 +18,7 @@ - - - -- - - -@@ -28,7 +28,7 @@ - - - -- - - diff --git a/patches/server/0012-Optimize-default-configurations.patch b/patches/server/features/0012-Optimize-default-configurations.patch similarity index 100% rename from patches/server/0012-Optimize-default-configurations.patch rename to patches/server/features/0012-Optimize-default-configurations.patch diff --git a/patches/server/0013-Add-an-option-to-apply-the-configuration-to-the-vani.patch b/patches/server/features/0013-Add-an-option-to-apply-the-configuration-to-the-vani.patch similarity index 100% rename from patches/server/0013-Add-an-option-to-apply-the-configuration-to-the-vani.patch rename to patches/server/features/0013-Add-an-option-to-apply-the-configuration-to-the-vani.patch diff --git a/patches/server/0028-Save-Json-list-asynchronously.patch b/patches/server/features/playerlist/0028-Save-Json-list-asynchronously.patch similarity index 100% rename from patches/server/0028-Save-Json-list-asynchronously.patch rename to patches/server/features/playerlist/0028-Save-Json-list-asynchronously.patch diff --git a/patches/server/0036-Load-player-data-asynchronously.patch b/patches/server/features/playerlist/0036-Load-player-data-asynchronously.patch similarity index 100% rename from patches/server/0036-Load-player-data-asynchronously.patch rename to patches/server/features/playerlist/0036-Load-player-data-asynchronously.patch diff --git a/patches/server/0027-Improve-SwingTime-ticking.patch b/patches/working/0027-Improve-SwingTime-ticking.patch similarity index 100% rename from patches/server/0027-Improve-SwingTime-ticking.patch rename to patches/working/0027-Improve-SwingTime-ticking.patch diff --git a/patches/server/0030-Use-Plazma-logo-instead-if-server-favicon-doesn-t-ex.patch b/patches/working/0030-Use-Plazma-logo-instead-if-server-favicon-doesn-t-ex.patch similarity index 100% rename from patches/server/0030-Use-Plazma-logo-instead-if-server-favicon-doesn-t-ex.patch rename to patches/working/0030-Use-Plazma-logo-instead-if-server-favicon-doesn-t-ex.patch diff --git a/patches/server/0034-Suppress-errors-from-dirty-attributes.patch b/patches/working/0034-Suppress-errors-from-dirty-attributes.patch similarity index 100% rename from patches/server/0034-Suppress-errors-from-dirty-attributes.patch rename to patches/working/0034-Suppress-errors-from-dirty-attributes.patch diff --git a/patches/server/0038-Optimize-advancement-criteria-triggering.patch b/patches/working/0038-Optimize-advancement-criteria-triggering.patch similarity index 100% rename from patches/server/0038-Optimize-advancement-criteria-triggering.patch rename to patches/working/0038-Optimize-advancement-criteria-triggering.patch diff --git a/plazma-api/paper-patches/files/src/main/java/com/destroystokyo/paper/MaterialTags.java.patch b/plazma-api/paper-patches/files/src/main/java/com/destroystokyo/paper/MaterialTags.java.patch new file mode 100644 index 0000000..166c3a0 --- /dev/null +++ b/plazma-api/paper-patches/files/src/main/java/com/destroystokyo/paper/MaterialTags.java.patch @@ -0,0 +1,59 @@ +--- a/src/main/java/com/destroystokyo/paper/MaterialTags.java ++++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java +@@ -37,10 +_,16 @@ + @SuppressWarnings({"NonFinalUtilityClass", "unused", "WeakerAccess"}) + public class MaterialTags { + +- private static NamespacedKey keyFor(String key) { +- //noinspection deprecation ++ @org.jetbrains.annotations.Contract("_ -> new") // Plazma ++ private static @org.jspecify.annotations.NonNull NamespacedKey keyFor(final @org.jspecify.annotations.NonNull String key) { // Plazma + return new NamespacedKey("paper", key + "_settag"); + } ++ ++ // Plazma start - Add missing docs ++ /** ++ * Covers all variants of arrows. ++ */ ++ // Plazma end - Add missing docs + public static final MaterialSetTag ARROWS = new MaterialSetTag(keyFor("arrows")) + .endsWith("ARROW") + .ensureSize("ARROWS", 3).lock(); +@@ -591,6 +_,22 @@ + .add(material -> material.name().startsWith("DEEPSLATE_") && material.name().endsWith("_ORE")) + .ensureSize("DEEPSLATE_ORES", 8).lock(); + ++ // Plazma start - Add more ores entries ++ /** ++ * Covers the variants of stone ores. ++ */ ++ public static final MaterialSetTag STONE_ORES = new MaterialSetTag(keyFor("stone_ores")) ++ .add(material -> material.name().endsWith("_ORE") && !material.name().startsWith("DEEPSLATE_") && !material.name().startsWith("NETHER_")) ++ .ensureSize("STONE_ORES", 8).lock(); ++ ++ /** ++ * Covers the variants of nether ores. ++ */ ++ public static final MaterialSetTag NETHER_ORES = new MaterialSetTag(keyFor("nether_ores")) ++ .add(material -> material.name().startsWith("NETHER_") && material.name().endsWith("_ORE")) ++ .ensureSize("NETHER_ORES", 2).lock(); ++ // Plazma end - Add more ores entries ++ + /** + * Covers the variants of raw ore blocks. + */ +@@ -720,5 +_,14 @@ + public static final MaterialSetTag NETHERITE_TOOLS = new MaterialSetTag(keyFor("netherite_tools")) + .add(Material.NETHERITE_AXE, Material.NETHERITE_HOE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD) + .ensureSize("NETHERITE_TOOLS", 5).lock(); ++ ++ // Plazma start - Add amethyst ++ /** ++ * Covers all amethyst buds/cluster. ++ */ ++ public static final MaterialSetTag AMETHYST_BUDS = new MaterialSetTag(keyFor("amethyst_buds")) ++ .add(Material.AMETHYST_CLUSTER).add(material -> material.name().endsWith("_AMETHYST_BUD")) ++ .ensureSize("AMETHYST_BUDS", 4).lock(); ++ // Plazma end - Add amethyst + + } diff --git a/plazma-server/minecraft-patches/features/0001-Remove-demo-feature.patch b/plazma-server/minecraft-patches/features/0001-Remove-demo-feature.patch index 57d04f1..2d66228 100644 --- a/plazma-server/minecraft-patches/features/0001-Remove-demo-feature.patch +++ b/plazma-server/minecraft-patches/features/0001-Remove-demo-feature.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Remove demo feature diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 57a3bc6c47468b40bb448a41cb6bb3d5eaecb5af..abfcde5bd61bd031ab555e70ce10f8d0df6e9bcd 100644 +index 42a2c150acf154d2184e0b422d3d97618c60a72c..6c54e929f87dd873e0713f5178c05e9c25eaa4c3 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -271,25 +271,25 @@ public class Main { +@@ -294,25 +294,25 @@ public class Main { LevelSettings levelSettings; WorldOptions worldOptions; WorldDimensions worldDimensions; @@ -50,16 +50,16 @@ index 57a3bc6c47468b40bb448a41cb6bb3d5eaecb5af..abfcde5bd61bd031ab555e70ce10f8d0 WorldDimensions.Complete complete = worldDimensions.bake(registry); Lifecycle lifecycle = complete.lifecycle().add(context.datapackWorldgen().allRegistriesLifecycle()); return new WorldLoader.DataLoadOutput<>( -@@ -322,7 +322,6 @@ public class Main { - if (optionSet.has("serverId")) { - dedicatedServer1.setId((String) optionSet.valueOf("serverId")); - } -- dedicatedServer1.setDemo(optionSet.has("demo")); - // Paper end - boolean flag = !optionSet.has("nogui") && !optionSet.nonOptionArguments().contains("nogui"); - if (flag && !GraphicsEnvironment.isHeadless()) { +@@ -348,7 +348,6 @@ public class Main { + if (optionSet.has("serverId")) { + server.setId((String) optionSet.valueOf("serverId")); + } +- dedicatedServer1.setDemo(optionSet.has("demo")); + // Paper end + + if (!optionSet.has("nogui") && !optionSet.nonOptionArguments().contains("nogui") && !GraphicsEnvironment.isHeadless()) { diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 74203ebce0f370a05014a7cf19e23be3a878b44d..4c3d5fab206a923dab0d8956bf74eae1f7e60625 100644 +index 83873873e3db91e178d2bddad7543494a7fc393e..ef5f1131e594036e318e2e1bdb0bf3d0abf8c0ab 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -603,24 +603,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb15703734a8b2ff 100644 +index 68c00479b02168281b4455c5fcf018aa4696d058..51ae9e838ba836b57c49d76dd95a08caa72539dc 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -533,7 +533,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -757,7 +757,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 this.playEntityOnFireExtinguishedSound(); } -@@ -2962,7 +2962,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2972,7 +2972,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public InteractionResult interact(Player player, InteractionHand hand) { if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { @@ -766,7 +766,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 if (hand == InteractionHand.OFF_HAND && (level().purpurConfig.villagerCanBeLeashed || level().purpurConfig.wanderingTraderCanBeLeashed) && this instanceof net.minecraft.world.entity.npc.AbstractVillager) return InteractionResult.CONSUME; // Purpur - Allow leashing villagers // CraftBukkit start - fire PlayerUnleashEntityEvent // Paper start - Expand EntityUnleashEvent -@@ -2980,14 +2980,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2990,14 +2990,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } this.gameEvent(GameEvent.ENTITY_INTERACT, player); @@ -783,7 +783,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 // CraftBukkit start - fire PlayerLeashEntityEvent if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) { ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); -@@ -2996,7 +2996,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3006,7 +3006,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } // CraftBukkit end leashable.setLeashedTo(player, true); @@ -792,7 +792,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 itemInHand.shrink(1); return InteractionResult.SUCCESS; -@@ -3072,7 +3072,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3082,7 +3082,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return false; } else if (!vehicle.couldAcceptPassenger()) { return false; @@ -801,7 +801,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 return false; } else { for (Entity entity = vehicle; entity.vehicle != null; entity = entity.vehicle) { -@@ -3161,7 +3161,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3171,7 +3171,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.passengers = ImmutableList.of(passenger); } else { List list = Lists.newArrayList(this.passengers); @@ -810,7 +810,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 list.add(0, passenger); } else { list.add(passenger); -@@ -3358,18 +3358,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3368,18 +3368,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public void handleEntityEvent(byte id) { @@ -832,7 +832,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 } public boolean isPassenger() { -@@ -3457,7 +3458,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3467,7 +3468,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public boolean isCurrentlyGlowing() { @@ -841,7 +841,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 } public boolean isInvisible() { -@@ -4192,8 +4193,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4202,8 +4203,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.eyeHeight = dimensions.eyeHeight(); this.reapplyPosition(); boolean flag = dimensions.width() <= 4.0F && dimensions.height() <= 4.0F; @@ -851,7 +851,7 @@ index ef32cca12f11c4a25bdf852f756e2e5a92e532a1..bd24ef83f9366806961b185ceb157037 && !this.noPhysics && flag && (dimensions.width() > entityDimensions.width() || dimensions.height() > entityDimensions.height()) -@@ -4458,7 +4458,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4468,7 +4468,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public boolean isEffectiveAi() { diff --git a/plazma-server/minecraft-patches/features/0003-Remove-Mojang-Profiler.patch b/plazma-server/minecraft-patches/features/0003-Remove-Mojang-Profiler.patch index 95adc1b..47c9174 100644 --- a/plazma-server/minecraft-patches/features/0003-Remove-Mojang-Profiler.patch +++ b/plazma-server/minecraft-patches/features/0003-Remove-Mojang-Profiler.patch @@ -147,7 +147,7 @@ index 18071dcc69cc28471dddb7de94e803ec1e5fc2e4..8b8ed964767177d9bda01a9ba1bec51d } } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 4c3d5fab206a923dab0d8956bf74eae1f7e60625..2d056c041e454fd2f724c6e42f21d435d527ba4f 100644 +index ef5f1131e594036e318e2e1bdb0bf3d0abf8c0ab..ba99735ce201330a7402e88a0fb2ea2b6327f20b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -114,19 +114,19 @@ import net.minecraft.util.TimeUtil; @@ -720,10 +720,10 @@ index a3192400b37274620977e5a40d4283bfec3ab9b3..a936031e38f8a1f40e484b55dcf0ac84 - } } diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 300e5b09b78089c8ea1e18e046012fae93a4f110..8e56b80201892238a43a90eb5b91ce6fc62f000a 100644 +index a1fdae645d1c7a8716690546c360b4dfa01c7c47..23a9e8936e39766f3d4db1f13fc9d5b02dd87b4a 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -767,11 +767,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -766,11 +766,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface return this.settings.getProperties().serverResourcePackInfo; } @@ -3739,7 +3739,7 @@ index 39a604c9a53930b53d959b1d2eb504aa964e9a58..e1366b8f3565800c8a90b7effe80b29f @Override diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be589c32682 100644 +index 51ae9e838ba836b57c49d76dd95a08caa72539dc..68b072b5ca2163fb164041151a5d134beef5a51d 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -78,8 +78,8 @@ import net.minecraft.tags.FluidTags; @@ -3822,7 +3822,7 @@ index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be5 } } // Paper start - detailed watchdog information -@@ -3325,8 +3325,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3335,8 +3335,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.processPortalCooldown(); if (this.portalProcess != null) { if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) { @@ -3833,7 +3833,7 @@ index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be5 this.setPortalCooldown(); TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { -@@ -3337,7 +3337,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3347,7 +3347,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -3842,7 +3842,7 @@ index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be5 } else if (this.portalProcess.hasExpired()) { this.portalProcess = null; } -@@ -3858,15 +3858,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3868,15 +3868,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess entity.teleport(this.calculatePassengerTransition(teleportTransition, entity)); } @@ -3861,7 +3861,7 @@ index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be5 return this; } -@@ -3882,11 +3882,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3892,11 +3892,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -3876,7 +3876,7 @@ index bd24ef83f9366806961b185ceb15703734a8b2ff..6b6a19a90ca7958a8ac864b9d6e61be5 return null; } else { // Paper start - Fix item duplication and teleport issues -@@ -3909,7 +3909,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3919,7 +3919,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess level.resetEmptyTime(); teleportTransition.postTeleportTransition().onTransition(entityx); diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch index 8de9455..3cf9d61 100644 --- a/plazma-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch +++ b/plazma-server/minecraft-patches/sources/net/minecraft/server/Main.java.patch @@ -65,9 +65,135 @@ Path path = (Path) optionSet.valueOf("pidFile"); // CraftBukkit if (path != null) { -@@ -243,12 +_,12 @@ +@@ -118,16 +_,20 @@ + Bootstrap.bootStrap(); + Bootstrap.validate(); + Util.startTimerHackThread(); +- Path path1 = Paths.get("server.properties"); ++ ++ Path serverProperties = Paths.get("server.properties"); // Plazma + DedicatedServerSettings dedicatedServerSettings = new DedicatedServerSettings(optionSet); // CraftBukkit - CLI argument support + dedicatedServerSettings.forceSave(); + RegionFileVersion.configure(dedicatedServerSettings.getProperties().regionFileComression); +- Path path2 = Paths.get("eula.txt"); +- Eula eula = new Eula(path2); ++ ++ Path eulaTxt = Paths.get("eula.txt"); // Plazma ++ Eula eula = new Eula(eulaTxt); // Plazma ++ + // Paper start - load config files early for access below if needed + org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionSet.valueOf("bukkit-settings")); + org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionSet.valueOf("spigot-settings")); + // Paper end - load config files early for access below if needed ++ + if (optionSet.has("initSettings")) { // CraftBukkit + // CraftBukkit start - SPIGOT-5761: Create bukkit.yml and commands.yml if not present + File configFile = (File) optionSet.valueOf("bukkit-settings"); +@@ -142,7 +_,7 @@ + commandsConfiguration.setDefaults(org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(new java.io.InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/commands.yml"), com.google.common.base.Charsets.UTF_8))); + commandsConfiguration.save(commandFile); + // CraftBukkit end +- LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath()); ++ LOGGER.info("Initialized '{}' and '{}'", serverProperties.toAbsolutePath(), eulaTxt.toAbsolutePath()); // Plazma + return; } - File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); + +@@ -152,8 +_,7 @@ + LOGGER.error("You have used the Spigot command line EULA agreement flag."); + LOGGER.error("By using this setting you are indicating your agreement to Mojang's EULA (https://aka.ms/MinecraftEULA)."); + LOGGER.error("If you do not agree to the above EULA please stop your server and remove this flag immediately."); +- } +- if (!eula.hasAgreedToEULA() && !eulaAgreed) { ++ } else if (!eula.hasAgreedToEULA()) { // Plazma + // Spigot end + LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); + return; +@@ -171,27 +_,43 @@ + } + // Paper end - Detect headless JRE + +- org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init +- + // Paper start - fix SPIGOT-5824 +- File file; +- File userCacheFile = new File(Services.USERID_CACHE_FILE); ++ final File worldDir; // Plazma + if (optionSet.has("universe")) { +- file = (File) optionSet.valueOf("universe"); // CraftBukkit +- userCacheFile = new File(file, Services.USERID_CACHE_FILE); ++ worldDir = (File) optionSet.valueOf("universe"); // CraftBukkit // Plazma + } else { +- file = new File(bukkitConfiguration.getString("settings.world-container", ".")); ++ worldDir = new File(bukkitConfiguration.getString("settings.world-container", ".")); // Plazma + } + // Paper end - fix SPIGOT-5824 +- Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionSet); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container +- // CraftBukkit start +- String string = Optional.ofNullable((String) optionSet.valueOf("world")).orElse(dedicatedServerSettings.getProperties().levelName); +- LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(file.toPath()); +- LevelStorageSource.LevelStorageAccess levelStorageAccess = levelStorageSource.validateAndCreateAccess(string, LevelStem.OVERWORLD); +- // CraftBukkit end +- Dynamic dataTag; ++ ++ // Plazma start - Configurable usercache.json file path ++ final File userCacheFile; // Plazma - Moved down ++ if (optionSet.has("usercache")) { ++ userCacheFile = (File) optionSet.valueOf("usercache"); ++ } else { ++ final @Nullable String bukkit = bukkitConfiguration.getString("settings.user-cache"); ++ if (bukkit != null && !bukkit.isBlank()) { ++ userCacheFile = new File(bukkit); ++ } else { ++ userCacheFile = new File(worldDir, Services.USERID_CACHE_FILE); ++ } ++ } ++ // Plazma end - Configurable usercache.json file path ++ ++ org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init // Plazma - moved down ++ final Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), worldDir, userCacheFile, optionSet); // Paper - pass OptionSet to load paper config files; override authentication service; fix world-container // Plazma ++ ++ // CraftBukkit start // Plazma start - Improve variable name ++ final String levelPrefix = Optional.ofNullable((String) optionSet.valueOf("world")).orElse(dedicatedServerSettings.getProperties().levelName); ++ final LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(worldDir.toPath()); ++ final LevelStorageSource.LevelStorageAccess levelStorageAccess = levelStorageSource.validateAndCreateAccess(levelPrefix, LevelStem.OVERWORLD); ++ // CraftBukkit end // Plazma end - Improve variable name ++ ++ final Dynamic dynamic; // Plazma - Moved up + if (levelStorageAccess.hasWorldData()) { ++ Dynamic dataTag; // Plazma + LevelSummary summary; ++ + try { + dataTag = levelStorageAccess.getDataTag(); + summary = levelStorageAccess.getSummary(dataTag); +@@ -225,163 +_,130 @@ + LOGGER.info("This world was created by an incompatible version."); + return; + } ++ ++ dynamic = dataTag; // Plazma + } else { +- dataTag = null; ++ dynamic = null; // Plazma + } + +- Dynamic dynamic = dataTag; +- boolean hasOptionSpec = optionSet.has("safeMode"); // CraftBukkit +- if (hasOptionSpec) { ++ final PackRepository packRepository = ServerPacksSource.createPackRepository(levelStorageAccess); // Plazma - moved up ++ final boolean safeMode = optionSet.has("safeMode"); // CraftBukkit // Plazma ++ if (safeMode) { // Plazma + LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); + } + +- PackRepository packRepository = ServerPacksSource.createPackRepository(levelStorageAccess); +- // CraftBukkit start +- File bukkitDataPackFolder = new File(levelStorageAccess.getLevelPath(net.minecraft.world.level.storage.LevelResource.DATAPACK_DIR).toFile(), "bukkit"); +- if (!bukkitDataPackFolder.exists()) { +- bukkitDataPackFolder.mkdirs(); +- } +- File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); ++ // CraftBukkit start // Plazma start - Improve code quality try { - com.google.common.io.Files.write("{\n" - + " \"pack\": {\n" @@ -75,19 +201,32 @@ - + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(net.minecraft.server.packs.PackType.SERVER_DATA) + "\n" - + " }\n" - + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); -+ com.google.common.io.Files.asCharSink(mcMeta, com.google.common.base.Charsets.UTF_8).write("{\n" -+ + " \"pack\": {\n" -+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(net.minecraft.server.packs.PackType.SERVER_DATA) + "\n" -+ + " }\n" -+ + "}\n"); ++ final File packDir = new File(levelStorageAccess.getLevelPath(net.minecraft.world.level.storage.LevelResource.DATAPACK_DIR).toFile(), "bukkit"); // Plazma ++ if (!packDir.exists() && !packDir.mkdirs()) { ++ throw new IOException("Unable to create Bukkit datapack folder"); ++ } ++ ++ final File mcMeta = new File(packDir, "pack.mcmeta"); ++ com.google.common.io.Files.asCharSink(mcMeta, com.google.common.base.Charsets.UTF_8).write(String.format(""" ++ { ++ "pack": { ++ "description": "Data pack for resources provided by Bukkit plugins", ++ "pack_format": %s ++ } ++ } ++ """, SharedConstants.getCurrentVersion().getPackVersion(net.minecraft.server.packs.PackType.SERVER_DATA))); } catch (java.io.IOException ex) { throw new RuntimeException("Could not initialize Bukkit datapack", ex); } -@@ -258,75 +_,53 @@ - WorldStem worldStem; +- java.util.concurrent.atomic.AtomicReference worldLoader = new java.util.concurrent.atomic.AtomicReference<>(); +- // CraftBukkit end ++ // CraftBukkit end // Plazma end - Improve code quality + +- WorldStem worldStem; ++ final WorldStem worldStem; // Plazma ++ final java.util.concurrent.atomic.AtomicReference worldLoader = new java.util.concurrent.atomic.AtomicReference<>(); // Plazma - moved down try { - WorldLoader.InitConfig initConfig = loadOrCreateConfig(dedicatedServerSettings.getProperties(), dynamic, hasOptionSpec, packRepository); +- WorldLoader.InitConfig initConfig = loadOrCreateConfig(dedicatedServerSettings.getProperties(), dynamic, hasOptionSpec, packRepository); - worldStem = Util.blockUntilDone( - executor -> WorldLoader.load( - initConfig, @@ -144,6 +283,35 @@ - "Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", - (Throwable)var39 - ); +- return; +- } +- +- /* +- RegistryAccess.Frozen frozen = worldStem.registries().compositeAccess(); +- boolean hasOptionSpec1 = optionSet.has(optionSpec6); +- if (optionSet.has(optionSpec4) || hasOptionSpec1) { +- forceUpgrade(levelStorageAccess, DataFixers.getDataFixer(), optionSet.has(optionSpec5), () -> true, frozen, hasOptionSpec1); +- } +- +- WorldData worldData = worldStem.worldData(); +- levelStorageAccess.saveDataTag(frozen, worldData); +- */ +- Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async +- final DedicatedServer dedicatedServer = MinecraftServer.spin( +- thread1 -> { +- DedicatedServer dedicatedServer1 = new DedicatedServer( +- // CraftBukkit start +- optionSet, +- worldLoader.get(), +- thread1, +- levelStorageAccess, +- packRepository, +- worldStem, +- dedicatedServerSettings, +- DataFixers.getDataFixer(), +- services, +- LoggerChunkProgressListener::createFromGameruleRadius ++ WorldLoader.InitConfig initConfig = loadOrCreateConfig(dedicatedServerSettings.getProperties(), dynamic, safeMode, packRepository); // Plazma + worldStem = Util.blockUntilDone((executor) -> WorldLoader.load(initConfig, (context) -> { + worldLoader.set(context); // CraftBukkit + Registry registry = context.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM); @@ -184,49 +352,34 @@ + return new WorldLoader.DataLoadOutput<>( + new PrimaryLevelData(levelSettings, worldOptions, complete.specialWorldProperty(), lifecycle), + complete.dimensionsRegistryAccess() -+ ); -+ }, WorldStem::new, Util.backgroundExecutor(), executor)).get(); -+ } catch (final Exception e) { // Plazma -+ LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", e); // Plazma - return; - } - -- /* -- RegistryAccess.Frozen frozen = worldStem.registries().compositeAccess(); -- boolean hasOptionSpec1 = optionSet.has(optionSpec6); -- if (optionSet.has(optionSpec4) || hasOptionSpec1) { -- forceUpgrade(levelStorageAccess, DataFixers.getDataFixer(), optionSet.has(optionSpec5), () -> true, frozen, hasOptionSpec1); -- } -- -- WorldData worldData = worldStem.worldData(); -- levelStorageAccess.saveDataTag(frozen, worldData); -- */ - Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async - final DedicatedServer dedicatedServer = MinecraftServer.spin( - thread1 -> { -@@ -343,18 +_,12 @@ - services, - LoggerChunkProgressListener::createFromGameruleRadius ); - /* - dedicatedServer1.setPort(optionSet.valueOf(optionSpec11)); - */ - // Paper start - if (optionSet.has("serverId")) { - dedicatedServer1.setId((String) optionSet.valueOf("serverId")); - } - dedicatedServer1.setDemo(optionSet.has("demo")); - // Paper end +- // Paper start +- if (optionSet.has("serverId")) { +- dedicatedServer1.setId((String) optionSet.valueOf("serverId")); +- } +- dedicatedServer1.setDemo(optionSet.has("demo")); +- // Paper end - /* - dedicatedServer1.setId(optionSet.valueOf(optionSpec12)); - */ - boolean flag = !optionSet.has("nogui") && !optionSet.nonOptionArguments().contains("nogui"); - if (flag && !GraphicsEnvironment.isHeadless()) { - dedicatedServer1.showGui(); -@@ -370,16 +_,6 @@ - return dedicatedServer1; - } - ); +- boolean flag = !optionSet.has("nogui") && !optionSet.nonOptionArguments().contains("nogui"); +- if (flag && !GraphicsEnvironment.isHeadless()) { +- dedicatedServer1.showGui(); +- } +- +- if (optionSet.has("port")) { +- int port = (Integer) optionSet.valueOf("port"); +- if (port > 0) { +- dedicatedServer1.setPort(port); +- } +- } +- +- return dedicatedServer1; +- } +- ); - /* CraftBukkit start - Thread thread = new Thread("Server Shutdown Thread") { - @Override @@ -237,9 +390,56 @@ - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); - Runtime.getRuntime().addShutdownHook(thread); - */ // CraftBukkit end ++ }, WorldStem::new, Util.backgroundExecutor(), executor)).get(); ++ } catch (final Exception e) { // Plazma ++ LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", e); // Plazma ++ return; ++ } ++ ++ Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async ++ ++ // Plazma start - Improve code quality ++ // noinspection resource ++ MinecraftServer.spin(thread -> { ++ final DedicatedServer server = new DedicatedServer( ++ // CraftBukkit start ++ optionSet, ++ worldLoader.get(), ++ thread, ++ levelStorageAccess, ++ packRepository, ++ worldStem, ++ dedicatedServerSettings, ++ DataFixers.getDataFixer(), ++ services, ++ LoggerChunkProgressListener::createFromGameruleRadius ++ ); ++ ++ // Paper start ++ if (optionSet.has("serverId")) { ++ server.setId((String) optionSet.valueOf("serverId")); ++ } ++ dedicatedServer1.setDemo(optionSet.has("demo")); ++ // Paper end ++ ++ if (!optionSet.has("nogui") && !optionSet.nonOptionArguments().contains("nogui") && !GraphicsEnvironment.isHeadless()) { ++ server.showGui(); ++ } ++ ++ if (optionSet.has("port")) { ++ int port = (Integer) optionSet.valueOf("port"); ++ if (port > 0) server.setPort(port); ++ } ++ ++ return server; ++ }); ++ // Plazma end - Improve code quality } catch (Exception var42) { - LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)var42); +- LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)var42); ++ LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", var42); // Plazma - Remove unnecessary type casting } + } + @@ -443,7 +_,7 @@ } else { try { diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch index c130060..c94c07d 100644 --- a/plazma-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/plazma-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -696,3 +696,12 @@ bufferedWriter.write(string); bufferedWriter.write("\n"); } +@@ -2768,7 +_,7 @@ + public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { + // Paper start + net.kyori.adventure.text.Component string = io.papermc.paper.adventure.PaperAdventure.asAdventure(boundChatType.decorate(content)); +- if (header != null) { ++ if (org.plazmamc.plazma.Options.global().consoleLogs.notSecurePrefix && header != null) { + COMPONENT_LOGGER.info("[{}] {}", header, string); + } else { + COMPONENT_LOGGER.info("{}", string); diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index 8837e3b..d5bc98b 100644 --- a/plazma-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/plazma-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -86,6 +86,23 @@ System.setOut(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(org.apache.logging.log4j.Level.INFO).buildPrintStream()); System.setErr(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(org.apache.logging.log4j.Level.WARN).buildPrintStream()); +@@ -183,16 +_,6 @@ + LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); + } + +- // Paper start - detect running as root +- if (io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { +- LOGGER.warn("****************************"); +- LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); +- LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); +- LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); +- LOGGER.warn("****************************"); +- } +- // Paper end - detect running as root +- + LOGGER.info("Loading properties"); + DedicatedServerProperties properties = this.settings.getProperties(); + if (this.isSingleplayer()) { @@ -208,6 +_,8 @@ org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); @@ -95,7 +112,7 @@ io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc. // Purpur start - Configurable void damage height and damage try { -@@ -218,10 +_,17 @@ +@@ -218,10 +_,27 @@ } org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur end - Configurable void damage height and damage @@ -109,6 +126,16 @@ + this.plazmaConfigurations.initializeGlobalConfiguration(this.registryAccess()); + this.plazmaConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); + // Plazma end - Configurable Plazma ++ ++ // Paper start - detect running as root // Plazma start - Tweak console logging (moved down) ++ if (org.plazmamc.plazma.Options.global().consoleLogs.rootUserWarning && io.papermc.paper.util.ServerEnvironment.userIsRootOrAdmin()) { ++ LOGGER.warn("****************************"); ++ LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED."); ++ LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS."); ++ LOGGER.warn("FOR MORE INFORMATION, SEE https://madelinemiller.dev/blog/root-minecraft-server/"); ++ LOGGER.warn("****************************"); ++ } ++ // Paper end - detect running as root // Plazma end - Tweak console logging (moved down) + this.server.spark.enableEarlyIfRequested(); // Paper - spark // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save @@ -140,7 +167,7 @@ } // Purpur start - UPnP Port Forwarding if (org.purpurmc.purpur.PurpurConfig.useUPnP) { -@@ -316,7 +_,6 @@ +@@ -316,44 +_,33 @@ // Purpur end - UPnP Port Forwarding // CraftBukkit start @@ -148,10 +175,38 @@ this.server.loadPlugins(); this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); // CraftBukkit end -@@ -342,18 +_,9 @@ - LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); - } +- // Paper start - Add Velocity IP Forwarding Support +- boolean usingProxy = org.spigotmc.SpigotConfig.bungee || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled; +- String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; +- String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; +- // Paper end - Add Velocity IP Forwarding Support +- if (!this.usesAuthentication()) { +- LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); ++ // Plazma start - Tweak console logging ++ final boolean usingVelocity = io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled; ++ if (!this.usesAuthentication() ++ && org.plazmamc.plazma.Options.global().consoleLogs.offlineWarnings ++ && (!usingVelocity || !io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.onlineMode) ++ ) { ++ LOGGER.warn("********** SERVER IS RUNNING IN OFFLINE/INSECURE MODE! **********"); + LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); +- // Spigot start +- // Paper start - Add Velocity IP Forwarding Support +- if (usingProxy) { +- LOGGER.warn("Whilst this makes it possible to use {}, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.", proxyFlavor); +- LOGGER.warn("Please see {} for further information.", proxyLink); +- // Paper end - Add Velocity IP Forwarding Support ++ if (usingVelocity || org.spigotmc.SpigotConfig.bungee) { ++ LOGGER.warn("Whilst this makes it possible to use {}, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.", usingVelocity ? "Velocity" : "BungeeCord"); ++ LOGGER.warn("Please see {} for further information.", usingVelocity ? "https://docs.papermc.io/velocity/security" : "https://www.spigotmc.org/wiki/firewall-guide/"); + } else { + LOGGER.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + } +- // Spigot end + LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); +- } +- - // CraftBukkit start - /* - if (this.convertOldUsers()) { @@ -159,7 +214,11 @@ - } - */ - // CraftBukkit end -- ++ LOGGER.warn("Or, if you understand exactly about this problem, and if you are prepared measures for it, change the \"console-logs.offline-warnings\" to \"false\" in the config/plazma-global.yml file."); ++ LOGGER.warn("This can suppress this warning, but you still need to be careful about related issues."); ++ } ++ // Plazma end - Tweak console logging + if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; } else { diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/world/RandomizableContainer.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/world/RandomizableContainer.java.patch new file mode 100644 index 0000000..4fd5cf3 --- /dev/null +++ b/plazma-server/minecraft-patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/RandomizableContainer.java ++++ b/net/minecraft/world/RandomizableContainer.java +@@ -88,6 +_,8 @@ + default void unpackLootTable(@Nullable final Player player, final boolean forceClearLootTable) { + // Paper end - LootTable API + Level level = this.getLevel(); ++ if (level.plazmaConfig().entity.populateLootTableOnlyForPlayerInteraction && player == null) return; // Plazma - Populate LootTable only for player interaction ++ + BlockPos blockPos = this.getBlockPos(); + ResourceKey lootTable = this.getLootTable(); + // Paper start - LootTable API diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch index b6d9eaf..46f02ce 100644 --- a/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -9,3 +9,78 @@ public boolean collisionLoadChunks = false; // Paper private @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; +@@ -2187,35 +_,45 @@ + } + + public void push(Entity entity) { +- if (!this.isPassengerOfSameVehicle(entity)) { +- if (!entity.noPhysics && !this.noPhysics) { +- if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant +- double d = entity.getX() - this.getX(); +- double d1 = entity.getZ() - this.getZ(); +- double max = Mth.absMax(d, d1); +- if (max >= 0.01F) { +- max = Math.sqrt(max); +- d /= max; +- d1 /= max; +- double d2 = 1.0 / max; +- if (d2 > 1.0) { +- d2 = 1.0; +- } +- +- d *= d2; +- d1 *= d2; +- d *= 0.05F; +- d1 *= 0.05F; +- if (!this.isVehicle() && this.isPushable()) { +- this.push(-d, 0.0, -d1); +- } +- +- if (!entity.isVehicle() && entity.isPushable()) { +- entity.push(d, 0.0, d1); +- } +- } +- } +- } ++ // Plazma start - Swaps the predicate order of collision - Based on Akarin ++ if (entity.noPhysics || this.noPhysics || this.isPassengerOfSameVehicle(entity)) { ++ return; ++ } ++ ++ if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) { // Paper - Collision option for requiring a player participant ++ return; ++ } ++ ++ double dX = entity.getX() - this.getX(); ++ double dZ = entity.getZ() - this.getZ(); ++ double max = Mth.absMax(dX, dZ); ++ if (max < 0.01F) { ++ return; ++ } ++ ++ max = Math.sqrt(max); ++ dX /= max; ++ dZ /= max; ++ ++ double maxPercent = 1.0 / max; ++ if (maxPercent > 1.0) { ++ maxPercent = 1.0; ++ } ++ ++ dX *= maxPercent; ++ dZ *= maxPercent; ++ dX *= 0.05F; ++ dZ *= 0.05F; ++ ++ if (!this.isVehicle() && this.isPushable()) { ++ this.push(-dX, 0.0, -dZ); ++ } ++ ++ if (!entity.isVehicle() && entity.isPushable()) { ++ entity.push(dX, 0.0, dZ); ++ } ++ ++ // Plazma end - Swaps the predicate order of collision + } + + public void push(Vec3 vector) { diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch new file mode 100644 index 0000000..66fea71 --- /dev/null +++ b/plazma-server/minecraft-patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/vehicle/ContainerEntity.java ++++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java +@@ -104,6 +_,8 @@ + } + + default void unpackChestVehicleLootTable(@Nullable Player player) { ++ if (this.level().plazmaConfig().entity.populateLootTableOnlyForPlayerInteraction && player == null) return; // Plazma - Populate LootTable only for player interaction ++ + MinecraftServer server = this.level().getServer(); + if (server != null && this.lootableData().shouldReplenish(this, com.destroystokyo.paper.loottable.PaperLootableInventoryData.ENTITY, player)) { // Paper - LootTable API + LootTable lootTable = server.reloadableRegistries().getLootTable(this.getContainerLootTable()); diff --git a/plazma-server/minecraft-patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/plazma-server/minecraft-patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch new file mode 100644 index 0000000..0411820 --- /dev/null +++ b/plazma-server/minecraft-patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/world/level/storage/PlayerDataStorage.java ++++ b/net/minecraft/world/level/storage/PlayerDataStorage.java +@@ -62,27 +_,30 @@ + + private Optional load(String name, String stringUuid, String suffix) { // CraftBukkit + File file = new File(this.playerDir, stringUuid + suffix); // CraftBukkit ++ final boolean exists = file.exists(); // Plazma - Avoid double I/O operation - Based on Akarin ++ + // Spigot start + boolean usingWrongFile = false; +- if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first +- file = new File(this.playerDir, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(java.nio.charset.StandardCharsets.UTF_8)).toString() + suffix); ++ if (org.bukkit.Bukkit.getOnlineMode() && !exists) { // Paper - Check online mode first // Plazma - Avoid double I/O operation - Based on Akarin ++ file = new File(this.playerDir, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(java.nio.charset.StandardCharsets.UTF_8)) + suffix); // Plazma - Remove unnecessary type casting + if (file.exists()) { + usingWrongFile = true; + LOGGER.warn("Using offline mode UUID file for player {} as it is the only copy we can find.", name); + } + } + // Spigot end +- if (file.exists() && file.isFile()) { ++ ++ if ((usingWrongFile || exists) && file.isFile()) { // Plazma - Avoid double I/O operation - Based on Akarin + try { + // Spigot start + Optional optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap())); +- if (usingWrongFile) { +- file.renameTo(new File(file.getPath() + ".offline-read")); ++ if (usingWrongFile && !file.renameTo(new File(file.getPath() + ".offline-read"))) { // Plazma - Throw if rename failed ++ throw new java.io.IOException("Failed to rename"); // Plazma - Throw if rename failed + } + return optional; + // Spigot end + } catch (Exception var5) { +- LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit ++ LOGGER.warn("Failed to load player data for {}", name, var5); // CraftBukkit // Plazma - Log exception + } + } + diff --git a/plazma-server/src/main/java/org/plazmamc/plazma/Options.java b/plazma-server/src/main/java/org/plazmamc/plazma/Options.java index cc3b16b..0921643 100644 --- a/plazma-server/src/main/java/org/plazmamc/plazma/Options.java +++ b/plazma-server/src/main/java/org/plazmamc/plazma/Options.java @@ -1,9 +1,18 @@ package org.plazmamc.plazma; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.plazmamc.plazma.configurations.GlobalConfiguration; + import static java.lang.Boolean.getBoolean; public interface Options { + @Contract(pure = true) + static @NotNull GlobalConfiguration global() { + return GlobalConfiguration.get(); + } + boolean ASYNC = getBoolean("Plazma.forciblyAllowAsyncAccess"); boolean OPTIMIZE = !getBoolean("Plazma.disableConfigOptimization"); boolean NO_WARN = getBoolean("Plazma.iKnowWhatIAmDoing"); diff --git a/plazma-server/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/plazma-server/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java index 561f111..5df871a 100644 --- a/plazma-server/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/plazma-server/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.Contract; import org.jspecify.annotations.NonNull; import org.spongepowered.configurate.objectmapping.meta.Setting; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "InnerClassMayBeStatic"}) public final class GlobalConfiguration extends ConfigurationPart { static GlobalConfiguration INSTANCE; @@ -20,4 +20,13 @@ public final class GlobalConfiguration extends ConfigurationPart { @Setting(Configurations.VERSION_FIELD) int version = VERSION; + public ConsoleLogs consoleLogs; + public class ConsoleLogs extends ConfigurationPart { + + public boolean offlineWarnings = true; + public boolean rootUserWarning = true; + public boolean notSecurePrefix = true; + + } + } diff --git a/plazma-server/src/main/java/org/plazmamc/plazma/configurations/WorldConfiguration.java b/plazma-server/src/main/java/org/plazmamc/plazma/configurations/WorldConfiguration.java index 5e8cbf7..bd7437c 100644 --- a/plazma-server/src/main/java/org/plazmamc/plazma/configurations/WorldConfiguration.java +++ b/plazma-server/src/main/java/org/plazmamc/plazma/configurations/WorldConfiguration.java @@ -5,7 +5,7 @@ import io.papermc.paper.configuration.Configurations; import net.minecraft.resources.ResourceLocation; import org.spongepowered.configurate.objectmapping.meta.Setting; -@SuppressWarnings({"unused", "FieldCanBeLocal"}) +@SuppressWarnings({"unused", "InnerClassMayBeStatic", "FieldCanBeLocal"}) public final class WorldConfiguration extends ConfigurationPart { static final int VERSION = 2; @@ -18,4 +18,11 @@ public final class WorldConfiguration extends ConfigurationPart { @Setting(Configurations.VERSION_FIELD) int version = VERSION; + public Entity entity; + public class Entity extends ConfigurationPart { + + public boolean populateLootTableOnlyForPlayerInteraction = OPTIMIZE; + + } + }