From 41df279b8bc026d49bb8326607109a50229a1613 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Thu, 28 Sep 2023 12:40:14 +0900 Subject: [PATCH] Some improvements --- .../server/0009-Console-logging-tweaks.patch | 31 ++++++++++++++- .../0023-Implement-No-Chat-Reports.patch | 8 ++-- .../0024-Fix-pufferfish-memory-leak.patch} | 14 +++---- .../server/0031-Reduce-Sensor-Work.patch | 38 ------------------- 4 files changed, 39 insertions(+), 52 deletions(-) rename patches/{unapplied/server/0030-Implement-MemoryLeakFix.patch => server/0024-Fix-pufferfish-memory-leak.patch} (79%) delete mode 100644 patches/unapplied/server/0031-Reduce-Sensor-Work.patch diff --git a/patches/server/0009-Console-logging-tweaks.patch b/patches/server/0009-Console-logging-tweaks.patch index 03b421a20..db21a73ed 100644 --- a/patches/server/0009-Console-logging-tweaks.patch +++ b/patches/server/0009-Console-logging-tweaks.patch @@ -4,6 +4,19 @@ Date: Wed, 27 Sep 2023 16:55:12 +0900 Subject: [PATCH] Console logging tweaks +diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +index e4fd372a1d585887287253a02531cd192929377b..dae0b0e1288afe0d8eb70d0e8e2db152aad42bf4 100644 +--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java ++++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +@@ -355,7 +355,7 @@ public final class ChatProcessor { + + private void sendToServer(final ChatType.Bound chatType, final @Nullable Function msgFunction) { + final PlayerChatMessage toConsoleMessage = msgFunction == null ? ChatProcessor.this.message : ChatProcessor.this.message.withUnsignedContent(msgFunction.apply(ChatProcessor.this.server.console)); +- ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage) ? null : "Not Secure"); ++ ChatProcessor.this.server.logChatMessage(toConsoleMessage.decoratedContent(), chatType, (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix || ChatProcessor.this.server.getPlayerList().verifyChatTrusted(toConsoleMessage)) ? null : "Not Secure"); // Plazma + } + } + diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java index a970e00482952318c258fc406cb7c39a229b65bc..879c090d9c4574a2cd45a0eb1bf9cb171834d940 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -56,11 +69,24 @@ index a970e00482952318c258fc406cb7c39a229b65bc..879c090d9c4574a2cd45a0eb1bf9cb17 if (!OldUsersConverter.serverReadyAfterUserconversion(this)) { return false; +diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java +index 5c38df8170033dbfee267520991a3cc3285d219e..58cc1bed851994fb591e9b832b98d25eda153b47 100644 +--- a/src/main/java/net/minecraft/server/players/PlayerList.java ++++ b/src/main/java/net/minecraft/server/players/PlayerList.java +@@ -1440,7 +1440,7 @@ public abstract class PlayerList { + } + public void broadcastChatMessage(PlayerChatMessage message, Predicate shouldSendFiltered, @Nullable ServerPlayer sender, ChatType.Bound params, @Nullable Function unsignedFunction) { + // Paper end +- boolean flag = this.verifyChatTrusted(message); ++ boolean flag = !org.plazmamc.plazma.configurations.GlobalConfiguration.get().consoleLogs.notSecurePrefix || this.verifyChatTrusted(message); // Plazma + + this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper + OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message); diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index b9a6c781684b080bcfb07495e561325d594eeafd..59c862c0e8a4111d4e9aa14a424b15cd9c37e6d1 100644 +index b9a6c781684b080bcfb07495e561325d594eeafd..81c6b6270fc7b74fdd1261fa1d14ec8221a36182 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -34,4 +34,12 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -34,4 +34,13 @@ public class GlobalConfiguration extends ConfigurationPart { public class Player extends ConfigurationPart { } @@ -70,6 +96,7 @@ index b9a6c781684b080bcfb07495e561325d594eeafd..59c862c0e8a4111d4e9aa14a424b15cd + + public boolean offlineWarnings = true; + public boolean rootUserWarnings = true; ++ public boolean notSecurePrefix = true; + + } } diff --git a/patches/server/0023-Implement-No-Chat-Reports.patch b/patches/server/0023-Implement-No-Chat-Reports.patch index 8577adca5..f77808aa7 100644 --- a/patches/server/0023-Implement-No-Chat-Reports.patch +++ b/patches/server/0023-Implement-No-Chat-Reports.patch @@ -111,7 +111,7 @@ index 6f6228edfe77668552a40a814ab3cebd74c4cb5a..22f26761965d3c03b109939585ff528d if (packet == null || this.processedDisconnect) { // Spigot return; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 5c38df8170033dbfee267520991a3cc3285d219e..d1702a97fc6aa5d427186209e5d282089c3a5af7 100644 +index 58cc1bed851994fb591e9b832b98d25eda153b47..4fbe96813067d3ccf1d8f29151ac3fac0840d76f 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1471,6 +1471,7 @@ public abstract class PlayerList { @@ -123,11 +123,11 @@ index 5c38df8170033dbfee267520991a3cc3285d219e..d1702a97fc6aa5d427186209e5d28208 } diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 065a4113f0b1dc1ee122af34609d0de02f62f9de..b7624af6896083e4a4190e7c0a3fc0a3260f5c27 100644 +index 10b42754e872a6c05005c2a129c016e7f53fe516..fa9e3df5be290acfbfecdda93d042b0797e3d0f6 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -48,4 +48,22 @@ public class GlobalConfiguration extends ConfigurationPart { - public boolean rootUserWarnings = true; +@@ -49,4 +49,22 @@ public class GlobalConfiguration extends ConfigurationPart { + public boolean notSecurePrefix = true; } + diff --git a/patches/unapplied/server/0030-Implement-MemoryLeakFix.patch b/patches/server/0024-Fix-pufferfish-memory-leak.patch similarity index 79% rename from patches/unapplied/server/0030-Implement-MemoryLeakFix.patch rename to patches/server/0024-Fix-pufferfish-memory-leak.patch index 06b233a59..4fc641755 100644 --- a/patches/unapplied/server/0030-Implement-MemoryLeakFix.patch +++ b/patches/server/0024-Fix-pufferfish-memory-leak.patch @@ -1,13 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: IPECTER -Date: Tue, 28 Mar 2023 12:42:17 +0900 -Subject: [PATCH] Implement MemoryLeakFix +From: AlphaKR93 +Date: Thu, 28 Sep 2023 12:33:14 +0900 +Subject: [PATCH] Fix pufferfish memory leak -Original: fxmorin/MemoryLeakFix -Copyright (C) 2023 fxmorin diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index ed439b7e94646141c93a7dd3704d1cdeb5c27e16..2bddcaf8762ee7834c32622402a976bfad12d127 100644 +index ed439b7e94646141c93a7dd3704d1cdeb5c27e16..8c51973491005faa03c866c8472918d0817965ed 100644 --- a/src/main/java/net/minecraft/world/level/biome/Biome.java +++ b/src/main/java/net/minecraft/world/level/biome/Biome.java @@ -67,7 +67,7 @@ public final class Biome { @@ -15,7 +13,7 @@ index ed439b7e94646141c93a7dd3704d1cdeb5c27e16..2bddcaf8762ee7834c32622402a976bf private final BiomeSpecialEffects specialEffects; // Pufferfish start - use our cache - private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> { -+ private static final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> { // Plazma - MemoryLeakFix ++ private static final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> { // Plazma - Fix memory leak return Util.make(() -> { /* Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { @@ -24,7 +22,7 @@ index ed439b7e94646141c93a7dd3704d1cdeb5c27e16..2bddcaf8762ee7834c32622402a976bf long l = blockPos.asLong(); // Pufferfish start - gg.airplane.structs.Long2FloatAgingCache cache = this.temperatureCache.get(); -+ gg.airplane.structs.Long2FloatAgingCache cache = temperatureCache.get(); // Plazma - MemoryLeakFix ++ gg.airplane.structs.Long2FloatAgingCache cache = temperatureCache.get(); // Plazma - Fix memory leak float f = cache.getValue(l); if (!Float.isNaN(f)) { return f; diff --git a/patches/unapplied/server/0031-Reduce-Sensor-Work.patch b/patches/unapplied/server/0031-Reduce-Sensor-Work.patch deleted file mode 100644 index 36e65c498..000000000 --- a/patches/unapplied/server/0031-Reduce-Sensor-Work.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: IPECTER -Date: Wed, 3 May 2023 16:51:49 +0900 -Subject: [PATCH] Reduce Sensor Work - -Original: Bloom-host/Petal -Copyright (C) 2023 peaches94 - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 49906b4dc8392eee592215d0b4cba85267a875fc..a0759a2f1191cc44a0c441db180ad8bd300ff4a4 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1037,20 +1037,20 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - if (entity != null) { -- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); -+ //ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); // Plazma - EntityType entitytypes = entity.getType(); - - // Purpur start -- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)) { -+ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) { // Plazma - d0 *= entity.level().purpurConfig.skeletonHeadVisibilityPercent; - } -- else if (entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)) { -+ else if (entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) { // Plazma - d0 *= entity.level().purpurConfig.zombieHeadVisibilityPercent; - } -- else if (entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { -+ else if (entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Plazma - d0 *= entity.level().purpurConfig.creeperHeadVisibilityPercent; - } -- else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && itemstack.is(Items.PIGLIN_HEAD)) { -+ else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD)) { // Plazma - d0 *= entity.level().purpurConfig.piglinHeadVisibilityPercent; - } - // Purpur end