Skip to content

Commit

Permalink
Fix Exploits
Browse files Browse the repository at this point in the history
  • Loading branch information
IPECTER committed Dec 30, 2023
1 parent e654ff4 commit 1d3f62e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 7 deletions.
82 changes: 75 additions & 7 deletions patches/server/0009-Optimize-Default-Configurations.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ From: IPECTER <[email protected]>
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 {
Expand Down Expand Up @@ -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<String, Integer> 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 {
Expand All @@ -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<Class<? extends Packet<?>>, PacketLimit> overrides = Map.of(ServerboundPlaceRecipePacket.class, new PacketLimit(4.0, 5.0, PacketLimit.ViolateAction.DROP));
+ // Plazma start - Optimize Default Configurations
+ public Map<Class<? extends Packet<?>>, 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 {
Expand All @@ -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<MobCategory> spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1)));
Expand Down Expand Up @@ -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 {
Expand All @@ -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<DedicatedServerPropertie
Expand All @@ -233,7 +300,8 @@ index 1ea3012995c738c67b31e997c138f824f9e69ba1..8ed00a650b712cbf4bc8796165a539d7
this.opPermissionLevel = this.get("op-permission-level", 4);
this.functionPermissionLevel = this.get("function-permission-level", 2);
this.maxTickTime = this.get("max-tick-time", TimeUnit.MINUTES.toMillis(1L));
this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000);
- this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", 1000000);
+ this.maxChainedNeighborUpdates = this.get("max-chained-neighbor-updates", !Boolean.getBoolean("Plazma.disableConfigOptimization") ? 10000 : 1000000); // Plazma - Optimize Default Configurations
this.rateLimitPacketsPerSecond = this.get("rate-limit", 0);
- this.viewDistance = this.get("view-distance", 10);
- this.simulationDistance = this.get("simulation-distance", 10);
Expand Down
27 changes: 27 additions & 0 deletions patches/server/0046-Paper-Add-another-slot-sanity-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: IPECTER <[email protected]>
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();

0 comments on commit 1d3f62e

Please sign in to comment.