mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-23 08:49:18 +00:00
move small patches
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 16 Dec 2024 20:52:48 +0300
|
||||
Date: Sun, 12 Jan 2025 15:27:57 +0300
|
||||
Subject: [PATCH] lithium: fast_util
|
||||
|
||||
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
|
||||
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
||||
index 928f38fd6beb00753c92ae9f4678f7507519a39b..4c53995d6d173ff6f544d52f11b675015efde26e 100644
|
||||
--- a/src/main/java/net/minecraft/core/Direction.java
|
||||
+++ b/src/main/java/net/minecraft/core/Direction.java
|
||||
diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java
|
||||
index 216f97207dac88cc1dc3df59c6ee8a62c7614b4a..05c7de5729466786a0196fa5f91eccc3cfffc675 100644
|
||||
--- a/net/minecraft/core/Direction.java
|
||||
+++ b/net/minecraft/core/Direction.java
|
||||
@@ -217,7 +217,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
|
||||
}
|
||||
|
||||
@@ -28,10 +26,10 @@ index 928f38fd6beb00753c92ae9f4678f7507519a39b..4c53995d6d173ff6f544d52f11b67501
|
||||
}
|
||||
|
||||
public static Direction getApproximateNearest(double x, double y, double z) {
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
|
||||
index e74866e5195a5eeae7666ad7be750edac5947094..25d7e7116282ec4b2cf85fe0b8e920af77fe4206 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/AABB.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
|
||||
diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java
|
||||
index c9c6e4e460ad8435f12761704bb9b0284d6aa708..b4ae2ad4b6852b7c1042675dafcb15d136c20eab 100644
|
||||
--- a/net/minecraft/world/phys/AABB.java
|
||||
+++ b/net/minecraft/world/phys/AABB.java
|
||||
@@ -18,6 +18,15 @@ public class AABB {
|
||||
public final double maxY;
|
||||
public final double maxZ;
|
||||
@@ -43,12 +41,12 @@ index e74866e5195a5eeae7666ad7be750edac5947094..25d7e7116282ec4b2cf85fe0b8e920af
|
||||
+ assert Direction.Axis.Z.ordinal() == 2;
|
||||
+ assert Direction.Axis.values().length == 3;
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+ // DivineMC end - lithium: fast_util
|
||||
+
|
||||
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
this.minX = Math.min(x1, x2);
|
||||
this.minY = Math.min(y1, y2);
|
||||
@@ -86,11 +95,33 @@ public class AABB {
|
||||
@@ -79,11 +88,33 @@ public class AABB {
|
||||
}
|
||||
|
||||
public double min(Direction.Axis axis) {
|
||||
@@ -64,7 +62,7 @@ index e74866e5195a5eeae7666ad7be750edac5947094..25d7e7116282ec4b2cf85fe0b8e920af
|
||||
+ }
|
||||
+
|
||||
+ throw new IllegalArgumentException();
|
||||
+ // DivineMC end
|
||||
+ // DivineMC end - lithium: fast_util
|
||||
}
|
||||
|
||||
public double max(Direction.Axis axis) {
|
||||
@@ -80,7 +78,7 @@ index e74866e5195a5eeae7666ad7be750edac5947094..25d7e7116282ec4b2cf85fe0b8e920af
|
||||
+ }
|
||||
+
|
||||
+ throw new IllegalArgumentException();
|
||||
+ // DivineMC end
|
||||
+ // DivineMC end - lithium: fast_util
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,15 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Fri, 21 Jun 2024 04:19:11 +0300
|
||||
Subject: [PATCH] Parchment: Make FixLight use action bar
|
||||
|
||||
Original project: https://github.com/ProjectEdenGG/Parchment
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
index 85950a1aa732ab8c01ad28bec9e0de140e1a172e..a6df6eeeda88c50894e03742e25aa5652a770ba9 100644
|
||||
--- a/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
@@ -95,17 +95,20 @@ public final class FixLightCommand implements PaperSubcommand {
|
||||
--- a/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
+++ b/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
@@ -95,17 +_,22 @@
|
||||
((StarLightLightingProvider)lightengine).starlight$serverRelightChunks(chunks,
|
||||
(final ChunkPos chunkPos) -> {
|
||||
++relitChunks[0];
|
||||
@@ -17,13 +8,14 @@ index 85950a1aa732ab8c01ad28bec9e0de140e1a172e..a6df6eeeda88c50894e03742e25aa565
|
||||
- text("Relit chunk ", BLUE), text(chunkPos.toString()),
|
||||
- text(", progress: ", BLUE), text(ONE_DECIMAL_PLACES.get().format(100.0 * (double) (relitChunks[0]) / (double) pending[0]) + "%")
|
||||
- ));
|
||||
+ // DivineMC start - Make FixLight use action bar
|
||||
+ sender.getBukkitEntity().sendActionBar(text().color(DARK_AQUA).append(
|
||||
+ text("Relighting Chunks: ", DARK_AQUA), text(chunkPos.toString()),
|
||||
+ text(" " + relitChunks[0], net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text("/", DARK_AQUA),
|
||||
+ text(pending[0] + " ", net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text("(" + (int) (Math.round(100.0 * (double) (relitChunks[0]) / (double) pending[0])) + "%)", net.kyori.adventure.text.format.NamedTextColor.YELLOW)
|
||||
+ )); // DivineMC // Parchment - Make FixLight use action bar
|
||||
+ )); // DivineMC end - Make FixLight use action bar
|
||||
},
|
||||
(final int totalRelit) -> {
|
||||
final long end = System.nanoTime();
|
||||
@@ -31,9 +23,10 @@ index 85950a1aa732ab8c01ad28bec9e0de140e1a172e..a6df6eeeda88c50894e03742e25aa565
|
||||
- text("Relit ", BLUE), text(totalRelit),
|
||||
- text(" chunks. Took ", BLUE), text(ONE_DECIMAL_PLACES.get().format(1.0e-6 * (end - start)) + "ms")
|
||||
- ));
|
||||
+ // DivineMC start - Make FixLight use action bar
|
||||
+ text("Relit ", DARK_AQUA), text(totalRelit, net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text(" chunks. Took ", DARK_AQUA), text(ONE_DECIMAL_PLACES.get().format(1.0e-6 * (end - start)) + "ms", net.kyori.adventure.text.format.NamedTextColor.YELLOW)
|
||||
+ )); // DivineMC // Parchment - Make FixLight use action bar
|
||||
+ )); // DivineMC end - Make FixLight use action bar
|
||||
if (done != null) {
|
||||
done.run();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2387,6 +_,7 @@
|
||||
}
|
||||
|
||||
private void tryHandleChat(String message, Runnable handler, boolean sync) { // CraftBukkit
|
||||
+ if (ServerGamePacketListenerImpl.isLog4ShellExploit(message)) return; // DivineMC - Block Log4Shell exploit
|
||||
if (isChatMessageIllegal(message)) {
|
||||
this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect
|
||||
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
|
||||
@@ -2414,6 +_,15 @@
|
||||
return optional;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // DivineMC start - Block Log4Shell exploit
|
||||
+ public static boolean isLog4ShellExploit(String message) {
|
||||
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(".*\\$\\{[^}]*}.*");
|
||||
+ java.util.regex.Matcher matcher = pattern.matcher(message);
|
||||
+
|
||||
+ return matcher.find();
|
||||
+ }
|
||||
+ // DivineMC end - Block Log4Shell exploit
|
||||
|
||||
public static boolean isChatMessageIllegal(String message) {
|
||||
for (int i = 0; i < message.length(); i++) {
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/level/biome/BiomeManager.java
|
||||
+++ b/net/minecraft/world/level/biome/BiomeManager.java
|
||||
@@ -7,7 +_,8 @@
|
||||
import net.minecraft.util.LinearCongruentialGenerator;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
-public class BiomeManager {
|
||||
+public class
|
||||
+BiomeManager {
|
||||
public static final int CHUNK_CENTER_QUART = QuartPos.fromBlock(8);
|
||||
private static final int ZOOM_BITS = 2;
|
||||
private static final int ZOOM = 4;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
||||
@@ -69,7 +_,7 @@
|
||||
int height
|
||||
) {
|
||||
int i = 0;
|
||||
- BitSet bitSet = new BitSet(width * height * width);
|
||||
+ BitSet bitSet = space.bxteam.divinemc.util.c2me.ObjectCachingUtils.getCachedOrNewBitSet(width * height * width); // DivineMC - C2ME: reduce_allocs
|
||||
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
int i1 = config.size;
|
||||
double[] doubles = new double[i1 * 4];
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] DivineMC Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index c9cb1c64313fe107fcb66c3bde4e0bb88a7d6ab3..a5643267680262c2466b81bfe1a846027922d22f 100644
|
||||
index 4cf13628c0d304fbf658fcb6f09631b282c34bfa..fc5797fe93bfd23a3fae94e08d6bc131eb278eb6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1087,6 +1087,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1088,6 +1088,7 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur - Purpur config files
|
||||
@@ -16,7 +16,7 @@ index c9cb1c64313fe107fcb66c3bde4e0bb88a7d6ab3..a5643267680262c2466b81bfe1a84602
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
@@ -1103,6 +1104,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1104,6 +1105,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
world.spigotConfig.init(); // Spigot
|
||||
world.purpurConfig.init(); // Purpur - Purpur config files
|
||||
@@ -24,7 +24,7 @@ index c9cb1c64313fe107fcb66c3bde4e0bb88a7d6ab3..a5643267680262c2466b81bfe1a84602
|
||||
}
|
||||
|
||||
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||
@@ -1121,6 +1123,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1122,6 +1124,7 @@ public final class CraftServer implements Server {
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
this.spark.registerCommandBeforePlugins(this); // Paper - spark
|
||||
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur - Purpur config files
|
||||
@@ -32,7 +32,7 @@ index c9cb1c64313fe107fcb66c3bde4e0bb88a7d6ab3..a5643267680262c2466b81bfe1a84602
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -3064,6 +3067,13 @@ public final class CraftServer implements Server {
|
||||
@@ -3068,6 +3071,13 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
// Purpur end - Purpur config files
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -1,6 +_,5 @@
|
||||
package io.papermc.paper.plugin.manager;
|
||||
|
||||
-import co.aikar.timings.TimedEventExecutor;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
import com.destroystokyo.paper.exception.ServerEventException;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -36,15 +_,16 @@
|
||||
|
||||
// SimplePluginManager
|
||||
public void callEvent(@NotNull Event event) {
|
||||
+ // DivineMC start - Skip event if no listeners
|
||||
+ RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
+ if (listeners.length == 0) return;
|
||||
+ // DivineMC end - Skip event if no listeners
|
||||
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;
|
||||
@@ -95,7 +_,6 @@
|
||||
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
|
||||
}
|
||||
|
||||
- executor = new TimedEventExecutor(executor, plugin, null, event);
|
||||
this.getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
|
||||
}
|
||||
|
||||
@@ -182,7 +_,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- EventExecutor executor = new TimedEventExecutor(EventExecutor.create(method, eventClass), plugin, method, eventClass);
|
||||
+ EventExecutor executor = EventExecutor.create(method, eventClass);
|
||||
eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
|
||||
}
|
||||
return ret;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java
|
||||
@@ -232,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean useTimings() {
|
||||
- return co.aikar.timings.Timings.isTimingsEnabled();
|
||||
+ return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,15 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Sat, 13 Jan 2024 13:36:55 +0300
|
||||
Subject: [PATCH] Optimize CraftServer.getWorld(UUID)
|
||||
|
||||
Original code by MultiPaper - https://github.com/MultiPaper/MultiPaper
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index eab64b3f812c9ab12793ad200f58ae8c49e214e1..88343cbdaa95f7f2bf6a196b58f23195186749a2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -285,6 +285,7 @@ public final class CraftServer implements Server {
|
||||
@@ -285,6 +_,7 @@
|
||||
protected final DedicatedPlayerList playerList;
|
||||
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
|
||||
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
|
||||
@@ -17,7 +8,7 @@ index eab64b3f812c9ab12793ad200f58ae8c49e214e1..88343cbdaa95f7f2bf6a196b58f23195
|
||||
private YamlConfiguration configuration;
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
@@ -1519,6 +1520,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1521,6 +_,7 @@
|
||||
this.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -25,7 +16,7 @@ index eab64b3f812c9ab12793ad200f58ae8c49e214e1..88343cbdaa95f7f2bf6a196b58f23195
|
||||
this.worlds.remove(world.getName().toLowerCase(Locale.ROOT));
|
||||
this.console.removeLevel(handle);
|
||||
return true;
|
||||
@@ -1537,6 +1539,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1539,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public World getWorld(UUID uid) {
|
||||
@@ -33,7 +24,7 @@ index eab64b3f812c9ab12793ad200f58ae8c49e214e1..88343cbdaa95f7f2bf6a196b58f23195
|
||||
for (World world : this.worlds.values()) {
|
||||
if (world.getUID().equals(uid)) {
|
||||
return world;
|
||||
@@ -1560,6 +1563,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1562,6 +_,7 @@
|
||||
System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world.");
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package space.bxteam.divinemc.util.c2me;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
public class ObjectCachingUtils {
|
||||
private static final IntFunction<BitSet> bitSetConstructor = BitSet::new;
|
||||
|
||||
public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
|
||||
|
||||
private ObjectCachingUtils() {}
|
||||
|
||||
public static BitSet getCachedOrNewBitSet(int bits) {
|
||||
final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
|
||||
bitSet.clear();
|
||||
return bitSet;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Thu, 23 May 2024 02:06:30 +0300
|
||||
Subject: [PATCH] Block Log4Shell exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index c783c17d45beda8297171d0834350197808a7335..0fef16501c1a971dc8bd2616c7476dffabb6ea08 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2518,6 +2518,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
}
|
||||
|
||||
private void tryHandleChat(String s, Runnable runnable, boolean sync) { // CraftBukkit
|
||||
+ if (ServerGamePacketListenerImpl.isLog4ShellExploit(s)) return; // DivineMC - Block Log4Shell exploit
|
||||
if (ServerGamePacketListenerImpl.isChatMessageIllegal(s)) {
|
||||
this.disconnectAsync((Component) Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper // Paper - add proper async disconnect
|
||||
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
|
||||
@@ -2549,6 +2550,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
}
|
||||
}
|
||||
|
||||
+ // DivineMC start - Block Log4Shell exploit
|
||||
+ public static boolean isLog4ShellExploit(String message) {
|
||||
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(".*\\$\\{[^}]*}.*");
|
||||
+ java.util.regex.Matcher matcher = pattern.matcher(message);
|
||||
+
|
||||
+ return matcher.find();
|
||||
+ }
|
||||
+ // DivineMC end
|
||||
+
|
||||
public static boolean isChatMessageIllegal(String message) {
|
||||
for (int i = 0; i < message.length(); ++i) {
|
||||
if (!StringUtil.isAllowedChatCharacter(message.charAt(i))) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index c2df3c38f58d8dcb5e3d62077655af56a3bffd65..e77d8db58e1be82f64aa3a3abfc1c85a6e382967 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -767,6 +767,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
Preconditions.checkArgument(msg != null, "msg cannot be null");
|
||||
|
||||
if (this.getHandle().connection == null) return;
|
||||
+
|
||||
+ if (ServerGamePacketListenerImpl.isLog4ShellExploit(msg)) return; // DivineMC - Block Log4Shell exploit
|
||||
|
||||
// Paper start - Improve chat handling
|
||||
if (ServerGamePacketListenerImpl.isChatMessageIllegal(msg)) {
|
||||
@@ -1,45 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 13 May 2024 17:40:02 +0300
|
||||
Subject: [PATCH] C2ME: reduce_allocs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
||||
index 506b2afd099c9b7e9ac3f6f2fcea8e523fae396b..2394f6f2c031b25a6cbeb79918a04b5710548d98 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
||||
@@ -69,7 +69,7 @@ public class OreFeature extends Feature<OreConfiguration> {
|
||||
int verticalSize
|
||||
) {
|
||||
int i = 0;
|
||||
- BitSet bitSet = new BitSet(horizontalSize * verticalSize * horizontalSize);
|
||||
+ BitSet bitSet = space.bxteam.divinemc.util.c2me.ObjectCachingUtils.getCachedOrNewBitSet(horizontalSize * verticalSize * horizontalSize); // DivineMC - C2ME: reduce_allocs
|
||||
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
int j = config.size;
|
||||
double[] ds = new double[j * 4];
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java b/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..828b9cb2f6506b9775dfccc934e9a64d5ddfaeff
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/space/bxteam/divinemc/util/c2me/ObjectCachingUtils.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package space.bxteam.divinemc.util.c2me;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
+
|
||||
+import java.util.BitSet;
|
||||
+import java.util.function.IntFunction;
|
||||
+
|
||||
+public class ObjectCachingUtils {
|
||||
+ private static final IntFunction<BitSet> bitSetConstructor = BitSet::new;
|
||||
+
|
||||
+ public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
|
||||
+
|
||||
+ private ObjectCachingUtils() {}
|
||||
+
|
||||
+ public static BitSet getCachedOrNewBitSet(int bits) {
|
||||
+ final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
|
||||
+ bitSet.clear();
|
||||
+ return bitSet;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,61 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 18 Nov 2024 17:05:17 +0300
|
||||
Subject: [PATCH] Delete Timings
|
||||
|
||||
|
||||
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..a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.papermc.paper.plugin.manager;
|
||||
|
||||
-import co.aikar.timings.TimedEventExecutor;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
import com.destroystokyo.paper.exception.ServerEventException;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -95,7 +94,6 @@ class PaperEventManager {
|
||||
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
|
||||
}
|
||||
|
||||
- executor = new TimedEventExecutor(executor, plugin, null, event);
|
||||
this.getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
|
||||
}
|
||||
|
||||
@@ -182,7 +180,7 @@ class PaperEventManager {
|
||||
}
|
||||
}
|
||||
|
||||
- EventExecutor executor = new TimedEventExecutor(EventExecutor.create(method, eventClass), plugin, method, eventClass);
|
||||
+ EventExecutor executor = EventExecutor.create(method, eventClass);
|
||||
eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
|
||||
}
|
||||
return ret;
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java
|
||||
index 097500a59336db1bbfffcd1aa4cff7a8586e46ec..35b00c139864dd7925d46a2d6a317d7e3aae9638 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginManagerImpl.java
|
||||
@@ -232,7 +232,7 @@ public class PaperPluginManagerImpl implements PluginManager, DependencyContext
|
||||
|
||||
@Override
|
||||
public boolean useTimings() {
|
||||
- return co.aikar.timings.Timings.isTimingsEnabled();
|
||||
+ return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index f9fcd20d8388fb8a81158f88733007cc45ea7895..3b9e50aa3b47233af7af4857537431900c9b86ee 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -3,9 +3,6 @@ package net.minecraft.server;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
-import co.aikar.timings.Timings;
|
||||
-import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
-import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -1,309 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 16 Dec 2024 01:14:03 +0300
|
||||
Subject: [PATCH] lithium: hashed_list
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4ce5cf4f5e2974e3d87514aee920d296a973938e..baa6922fe4547f4fef5719bd54251531340ef44f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -119,9 +119,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public static final int TICKS_PER_DAY = 24000;
|
||||
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
|
||||
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
|
||||
- public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); // Paper - public
|
||||
+ public final List<TickingBlockEntity> blockEntityTickers = new space.bxteam.divinemc.util.lithium.HashedReferenceList<>(Lists.newArrayList()); // Paper - public // DivineMC - lithium: hashed_list
|
||||
protected final NeighborUpdater neighborUpdater;
|
||||
- private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
||||
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = new space.bxteam.divinemc.util.lithium.HashedReferenceList<>(Lists.newArrayList()); // DivineMC - lithium: hashed_list
|
||||
private boolean tickingBlockEntities;
|
||||
public final Thread thread;
|
||||
private final boolean isDebug;
|
||||
diff --git a/src/main/java/space/bxteam/divinemc/util/lithium/HashedReferenceList.java b/src/main/java/space/bxteam/divinemc/util/lithium/HashedReferenceList.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aafa3e581587e3593cec4bb19bd0417ea28d5e67
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/space/bxteam/divinemc/util/lithium/HashedReferenceList.java
|
||||
@@ -0,0 +1,281 @@
|
||||
+package space.bxteam.divinemc.util.lithium;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
||||
+import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import java.util.ListIterator;
|
||||
+import java.util.NoSuchElementException;
|
||||
+
|
||||
+/**
|
||||
+ * Wraps a {@link List} with a hash table which provides O(1) lookups for {@link Collection#contains(Object)}. The type
|
||||
+ * contained by this list must use reference-equality semantics.
|
||||
+ */
|
||||
+@SuppressWarnings("SuspiciousMethodCalls")
|
||||
+public class HashedReferenceList<T> implements List<T> {
|
||||
+ private final ReferenceArrayList<T> list;
|
||||
+ private final Reference2IntOpenHashMap<T> counter;
|
||||
+
|
||||
+ public HashedReferenceList(List<T> list) {
|
||||
+ this.list = new ReferenceArrayList<>();
|
||||
+ this.list.addAll(list);
|
||||
+
|
||||
+ this.counter = new Reference2IntOpenHashMap<>();
|
||||
+ this.counter.defaultReturnValue(0);
|
||||
+
|
||||
+ for (T obj : this.list) {
|
||||
+ this.counter.addTo(obj, 1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return this.list.size();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEmpty() {
|
||||
+ return this.list.isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean contains(Object o) {
|
||||
+ return this.counter.containsKey(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Iterator<T> iterator() {
|
||||
+ return this.listIterator();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Object[] toArray() {
|
||||
+ return this.list.toArray();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public <T1> T1[] toArray(T1 @NotNull [] a) {
|
||||
+ return this.list.toArray(a);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean add(T t) {
|
||||
+ this.trackReferenceAdded(t);
|
||||
+
|
||||
+ return this.list.add(t);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean remove(Object o) {
|
||||
+ this.trackReferenceRemoved(o);
|
||||
+
|
||||
+ return this.list.remove(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean containsAll(Collection<?> c) {
|
||||
+ for (Object obj : c) {
|
||||
+ if (!this.counter.containsKey(obj)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addAll(Collection<? extends T> c) {
|
||||
+ for (T obj : c) {
|
||||
+ this.trackReferenceAdded(obj);
|
||||
+ }
|
||||
+
|
||||
+ return this.list.addAll(c);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addAll(int index, Collection<? extends T> c) {
|
||||
+ for (T obj : c) {
|
||||
+ this.trackReferenceAdded(obj);
|
||||
+ }
|
||||
+
|
||||
+ return this.list.addAll(index, c);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean removeAll(@NotNull Collection<?> c) {
|
||||
+ if (this.size() >= 2 && c.size() > 4 && c instanceof List) {
|
||||
+ //HashReferenceList uses reference equality, so using ReferenceOpenHashSet is fine
|
||||
+ c = new ReferenceOpenHashSet<>(c);
|
||||
+ }
|
||||
+ this.counter.keySet().removeAll(c);
|
||||
+ return this.list.removeAll(c);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean retainAll(@NotNull Collection<?> c) {
|
||||
+ this.counter.keySet().retainAll(c);
|
||||
+ return this.list.retainAll(c);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ this.counter.clear();
|
||||
+ this.list.clear();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T get(int index) {
|
||||
+ return this.list.get(index);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T set(int index, T element) {
|
||||
+ T prev = this.list.set(index, element);
|
||||
+
|
||||
+ if (prev != element) {
|
||||
+ if (prev != null) {
|
||||
+ this.trackReferenceRemoved(prev);
|
||||
+ }
|
||||
+
|
||||
+ this.trackReferenceAdded(element);
|
||||
+ }
|
||||
+
|
||||
+ return prev;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void add(int index, T element) {
|
||||
+ this.trackReferenceAdded(element);
|
||||
+
|
||||
+ this.list.add(index, element);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T remove(int index) {
|
||||
+ T prev = this.list.remove(index);
|
||||
+
|
||||
+ if (prev != null) {
|
||||
+ this.trackReferenceRemoved(prev);
|
||||
+ }
|
||||
+
|
||||
+ return prev;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int indexOf(Object o) {
|
||||
+ return this.list.indexOf(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int lastIndexOf(Object o) {
|
||||
+ return this.list.lastIndexOf(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ListIterator<T> listIterator() {
|
||||
+ return this.listIterator(0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ListIterator<T> listIterator(int index) {
|
||||
+ return new ListIterator<>() {
|
||||
+ private final ListIterator<T> inner = HashedReferenceList.this.list.listIterator(index);
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasNext() {
|
||||
+ return this.inner.hasNext();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T next() {
|
||||
+ return this.inner.next();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasPrevious() {
|
||||
+ return this.inner.hasPrevious();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public T previous() {
|
||||
+ return this.inner.previous();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextIndex() {
|
||||
+ return this.inner.nextIndex();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int previousIndex() {
|
||||
+ return this.inner.previousIndex();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void remove() {
|
||||
+ int last = this.previousIndex();
|
||||
+
|
||||
+ if (last == -1) {
|
||||
+ throw new NoSuchElementException();
|
||||
+ }
|
||||
+
|
||||
+ T prev = HashedReferenceList.this.get(last);
|
||||
+
|
||||
+ if (prev != null) {
|
||||
+ HashedReferenceList.this.trackReferenceRemoved(prev);
|
||||
+ }
|
||||
+
|
||||
+ this.inner.remove();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void set(T t) {
|
||||
+ int last = this.previousIndex();
|
||||
+
|
||||
+ if (last == -1) {
|
||||
+ throw new NoSuchElementException();
|
||||
+ }
|
||||
+
|
||||
+ T prev = HashedReferenceList.this.get(last);
|
||||
+
|
||||
+ if (prev != t) {
|
||||
+ if (prev != null) {
|
||||
+ HashedReferenceList.this.trackReferenceRemoved(prev);
|
||||
+ }
|
||||
+
|
||||
+ HashedReferenceList.this.trackReferenceAdded(t);
|
||||
+ }
|
||||
+
|
||||
+ this.inner.remove();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void add(T t) {
|
||||
+ HashedReferenceList.this.trackReferenceAdded(t);
|
||||
+
|
||||
+ this.inner.add(t);
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<T> subList(int fromIndex, int toIndex) {
|
||||
+ return this.list.subList(fromIndex, toIndex);
|
||||
+ }
|
||||
+
|
||||
+ private void trackReferenceAdded(T t) {
|
||||
+ this.counter.addTo(t, 1);
|
||||
+ }
|
||||
+
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ private void trackReferenceRemoved(Object o) {
|
||||
+ if (this.counter.addTo((T) o, -1) <= 1) {
|
||||
+ this.counter.removeInt(o);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||
Date: Mon, 16 Dec 2024 20:19:27 +0300
|
||||
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 a1c9726d25479b5326fe2fa2b0f5a98d6b2da4c5..2219edf3e56a2eade1049f448360247f48e3c52a 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -35,15 +35,16 @@ class PaperEventManager {
|
||||
|
||||
// SimplePluginManager
|
||||
public void callEvent(@NotNull Event event) {
|
||||
+ // DivineMC start - Skip event if no listeners
|
||||
+ RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
+ if (listeners.length == 0) return;
|
||||
+ // DivineMC 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;
|
||||
Reference in New Issue
Block a user