From 1d3f62e28101127bd0a5b4b866f68e57f636c91f Mon Sep 17 00:00:00 2001 From: IPECTER Date: Sat, 30 Dec 2023 23:21:09 +0900 Subject: [PATCH 1/2] Fix Exploits --- ...0009-Optimize-Default-Configurations.patch | 82 +++++++++++++++++-- ...-Paper-Add-another-slot-sanity-check.patch | 27 ++++++ 2 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 patches/server/0046-Paper-Add-another-slot-sanity-check.patch diff --git a/patches/server/0009-Optimize-Default-Configurations.patch b/patches/server/0009-Optimize-Default-Configurations.patch index 24f5fb590..2203d87c4 100644 --- a/patches/server/0009-Optimize-Default-Configurations.patch +++ b/patches/server/0009-Optimize-Default-Configurations.patch @@ -3,11 +3,11 @@ From: IPECTER Date: Tue, 7 Mar 2023 12:28:34 +0900 Subject: [PATCH] Optimize Default Configurations -Original: YouHaveTrouble/minecraft-optimization, AkiraDevelopment/SimplyMC +Original: YouHaveTrouble/minecraft-optimization, YouHaveTrouble/minecraft-exploits-and-how-to-fix-them, AkiraDevelopment/SimplyMC Copyright (C) 2023 YouHaveTrouble, AkiraDevelopment diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -index b4e5fbace85c67e7bd347e6a90514bbc2c132d5e..edc8eba38af743167a8b78d34cb426d6929f9605 100644 +index b4e5fbace85c67e7bd347e6a90514bbc2c132d5e..7a74aa64458a4f3be4f284b4cfcdd57d687f620b 100644 --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java @@ -211,8 +211,8 @@ public class PufferfishConfig { @@ -42,8 +42,29 @@ index b4e5fbace85c67e7bd347e6a90514bbc2c132d5e..edc8eba38af743167a8b78d34cb426d6 "tick frequency. freq = (distanceToPlayer^2) / (2^value)", "If you want further away entities to tick less often, use 7.", "If you want further away entities to tick more often, try 9."); +@@ -253,8 +253,18 @@ public class PufferfishConfig { + public static Map projectileTimeouts; + private static void projectileTimeouts() { + // Set some defaults +- getInt("entity_timeouts.SNOWBALL", -1); +- getInt("entity_timeouts.LLAMA_SPIT", -1); ++ // Plazma start - Optimize Default Configurations ++ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) { ++ getInt("entity_timeouts.ARROW", 200); ++ getInt("entity_timeouts.EGG", 200); ++ getInt("entity_timeouts.ENDER_PEARL", 200); ++ getInt("entity_timeouts.SNOWBALL", 200); ++ getInt("entity_timeouts.LLAMA_SPIT", 200); ++ } else { ++ // Plazma end ++ getInt("entity_timeouts.SNOWBALL", -1); ++ getInt("entity_timeouts.LLAMA_SPIT", -1); ++ } // Plazma + setComment("entity_timeouts", + "These values define a entity's maximum lifespan. If an", + "entity is in this list and it has survived for longer than", diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 8d442c5a498ecf288a0cc0c54889c6e2fda849ce..205ce3456a3f6d28cc2c7cbc131ec0f63a461527 100644 +index 8d442c5a498ecf288a0cc0c54889c6e2fda849ce..2d6f1811358f1d99ef9e543672e7d1861671f1f1 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -103,7 +103,7 @@ public class GlobalConfiguration extends ConfigurationPart { @@ -55,8 +76,43 @@ index 8d442c5a498ecf288a0cc0c54889c6e2fda849ce..205ce3456a3f6d28cc2c7cbc131ec0f6 } public SpamLimiter spamLimiter; +@@ -198,7 +198,7 @@ public class GlobalConfiguration extends ConfigurationPart { + public BookSize bookSize; + + public class BookSize extends ConfigurationPart { +- public int pageMax = 2560; // TODO this appears to be a duplicate setting with one above ++ public int pageMax = !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 1024 : 2560; // TODO this appears to be a duplicate setting with one above // Plazma - Optimize Default Configurations + public double totalMultiplier = 0.98D; // TODO this should probably be merged into the above inner class + } + public boolean resolveSelectorsInBooks = false; +@@ -209,7 +209,15 @@ public class GlobalConfiguration extends ConfigurationPart { + public class PacketLimiter extends ConfigurationPart { + public Component kickMessage = Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED); + public PacketLimit allPackets = new PacketLimit(7.0, 500.0, PacketLimit.ViolateAction.KICK); +- public Map>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ // Plazma start - Optimize Default Configurations ++ public Map>, PacketLimit> overrides = new java.util.HashMap<>() {{ ++ put(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ if (!Boolean.getBoolean("Plazma.disableConfigOptimization")) { ++ put(net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket.class, new PacketLimit(1.0, 15.0, PacketLimit.ViolateAction.DROP)); ++ put(net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP)); ++ } ++ }}; ++ // Plazma end + + @ConfigSerializable + public record PacketLimit(@Required double interval, @Required double maxPacketRate, ViolateAction action) { +@@ -276,7 +284,7 @@ public class GlobalConfiguration extends ConfigurationPart { + executor.setMaximumPoolSize(_chatExecutorMaxSize); + } + } +- public int maxJoinsPerTick = 5; ++ public int maxJoinsPerTick = !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 3 : 5; // Plazma - Optimize Default Configurations + public boolean fixEntityPositionDesync = true; + public boolean loadPermissionsYmlBeforePlugins = true; + @Constraints.Min(4) diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -index a33de97340f14219291c4175e9194914cdf441db..f63b4ab2057176d4f1549200eef16e71c6018dc2 100644 +index a33de97340f14219291c4175e9194914cdf441db..84dd20cc9026ebb039d01c6edc263805b969d673 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -84,15 +84,15 @@ public class WorldConfiguration extends ConfigurationPart { @@ -80,6 +136,17 @@ index a33de97340f14219291c4175e9194914cdf441db..f63b4ab2057176d4f1549200eef16e71 } } +@@ -116,8 +116,8 @@ public class WorldConfiguration extends ConfigurationPart { + public ArmorStands armorStands; + + public class ArmorStands extends ConfigurationPart { +- public boolean doCollisionEntityLookups = true; +- public boolean tick = true; ++ public boolean doCollisionEntityLookups = Boolean.getBoolean("Plazma.disableConfigOptimization"); // Plazma - Optimize Default Configurations ++ public boolean tick = Boolean.getBoolean("Plazma.disableConfigOptimization");; // Plazma - Optimize Default Configurations + } + + public Markers markers; @@ -139,7 +139,7 @@ public class WorldConfiguration extends ConfigurationPart { @MergeMap public Reference2IntMap spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1))); @@ -197,7 +264,7 @@ index 24763d3d270c29c95e0b3e85111145234f660a62..18bc271a34ffba8c83743fef7eaf4a2c } diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java -index 5ed7acb332b8982a724e5002e12f18fe32dd4dd4..8a10f9b7b837c4d20eaf4a83827e36f14a180ea7 100644 +index 1a125a0a2bbcc1e3e54746ec97abe24c53f69819..4736f85292ff6f0ae2d433f59c37a77eb4436982 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -154,7 +154,7 @@ public class Main { @@ -210,7 +277,7 @@ index 5ed7acb332b8982a724e5002e12f18fe32dd4dd4..8a10f9b7b837c4d20eaf4a83827e36f1 File commandFile = (File) optionset.valueOf("commands-settings"); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index 1ea3012995c738c67b31e997c138f824f9e69ba1..8ed00a650b712cbf4bc8796165a539d76d390d0f 100644 +index 1ea3012995c738c67b31e997c138f824f9e69ba1..aa37c7a7bfe75064db9cf78e967a6644f61b0e09 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -120,7 +120,7 @@ public class DedicatedServerProperties extends Settings +Date: Sat, 30 Dec 2023 21:56:47 +0900 +Subject: [PATCH] Paper-Add-another-slot-sanity-check + +Backport of Paper ver/1.20.2 8493340 + +diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +index 20b328704981c088597359fe18c1d67c339c1c0f..af4951fdfa08dfff22df03950c26fdfc28c5a3cd 100644 +--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +@@ -424,6 +424,7 @@ public abstract class AbstractContainerMenu { + this.resetQuickCraft(); + } + } else if (this.quickcraftStatus == 1) { ++ if (slotIndex < 0) return; // Paper + slot = (Slot) this.slots.get(slotIndex); + itemstack = this.getCarried(); + if (AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && (this.quickcraftType == 2 || itemstack.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) { +@@ -600,6 +601,7 @@ public abstract class AbstractContainerMenu { + int i2; + + if (actionType == ClickType.SWAP) { ++ if (slotIndex < 0 || button < 0) return; // Paper + slot2 = (Slot) this.slots.get(slotIndex); + itemstack1 = playerinventory.getItem(button); + itemstack = slot2.getItem(); From b24ba6461d1dcbed1302b17a486c5aafc35634a5 Mon Sep 17 00:00:00 2001 From: IPECTER Date: Sat, 30 Dec 2023 23:51:03 +0900 Subject: [PATCH 2/2] Fix build.gradle.kts --- build.gradle.kts | 101 +++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 35 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 140e4ea92..9b6696b5a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,33 +23,53 @@ dependencies { paperclip("io.papermc:paperclip:3.0.3") } -subprojects { +allprojects { apply(plugin = "java") + apply(plugin = "maven-publish") + + java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + + publishing { + repositories { + maven { + name = "githubPackage" + url = uri("https://maven.pkg.github.com/PlazmaMC/Plazma") + + credentials { + username = System.getenv("GITHUB_USERNAME") + password = System.getenv("GITHUB_TOKEN") + } + } - java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + publications.register("gpr") { + from(components["java"]) + } } } } subprojects { - tasks.withType().configureEach { - options.encoding = "UTF-8" - options.release.set(17) - } + apply(plugin = "java") - tasks.withType { - options.encoding = Charsets.UTF_8.name() - } + tasks { + withType().configureEach { + options.compilerArgs.add("--add-modules=jdk.incubator.vector") + options.encoding = Charsets.UTF_8.name() + options.release.set(17) + } - tasks.withType { - filteringCharset = Charsets.UTF_8.name() - } + withType { + options.encoding = Charsets.UTF_8.name() + } - tasks.withType { - minHeapSize = "2g" - maxHeapSize = "2g" + withType { + filteringCharset = Charsets.UTF_8.name() + } + + withType { + minHeapSize = "2g" + maxHeapSize = "2g" + } } repositories { @@ -83,28 +103,39 @@ paperweight { } } -val upstreamTask = tasks.register("updateUpstream") { - val tempDir = layout.cacheDir("updateUpstream"); - val file = "gradle.properties"; - - doFirst { - val apiResponse = layout.cache.resolve("apiResponse.json"); - download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", apiResponse); - val latestCommit = gson.fromJson(apiResponse)["sha"].asString; +tasks { + generateDevelopmentBundle { + apiCoordinates.set("org.plazmamc.plazma:plazma-api") + mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") + libraryRepositories.addAll( + "https://repo.maven.apache.org/maven2/", + "https://papermc.io/repo/repository/maven-public/" + ) + } - copy { - from(file) - into(tempDir) - filter { line: String -> - line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit") + register("updateUpstream") { + val tempDir = layout.cacheDir("updateUpstream"); + val file = "gradle.properties"; + + doFirst { + val apiResponse = layout.cache.resolve("apiResponse.json"); + download.get().download("https://api.github.com/repos/PaperMC/Paper/commits/master", apiResponse); + val latestCommit = gson.fromJson(apiResponse)["sha"].asString; + + copy { + from(file) + into(tempDir) + filter { line: String -> + line.replace("paperCommit = .*".toRegex(), "paperCommit = $latestCommit") + } } } - } - doLast { - copy { - from(tempDir.file("gradle.properties")) - into(project.file(file).parent) + doLast { + copy { + from(tempDir.file("gradle.properties")) + into(project.file(file).parent) + } } } }