9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/paper-patches/features/0016-CraftBukkit-UUID-to-world-map.patch
Dreeam c8ba5fedc8 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@9b1798d6 Simplify custom payload handling (#12347)
PaperMC/Paper@2552abf0 fix message mutation in PlayerSetSpawnEvent
PaperMC/Paper@ae99e24f fix deprecated bungee chat api methods
PaperMC/Paper@dca4aab8 add util methods to CraftChatMessage
PaperMC/Paper@87c9d9b0 be more lenient on url parsing for legacy format
PaperMC/Paper@4a9bd2e3 Correctly clear items in PlayerDeathEvent
PaperMC/Paper@a70f7745 fix unsaveable launched trident
PaperMC/Paper@41a094cf move block data/state impl
PaperMC/Paper@6b26b219 remove hardcoded durability from material
PaperMC/Paper@db8c646d Merge remote-tracking branch 'origin/main' into update/1.21.5
2025-03-31 09:53:16 -04:00

57 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sat, 24 Dec 2022 13:09:34 +0100
Subject: [PATCH] CraftBukkit UUID to world map
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
This patch is based on the following patch:
"Optimize CraftServer.getWorld(UUID)"
By: PureGero <puregero@gmail.com>
As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0a84d8cbdcd3513a83487a22ba81dc9e0535fc1b..45296a3d27ecd70375ea17c1375d05c70f10f9d2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -282,6 +282,7 @@ public final class CraftServer implements Server {
final DedicatedServer console;
private final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<>();
+ private final it.unimi.dsi.fastutil.objects.Object2ObjectMap<UUID, World> worldsByUUID = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(); // Gale - MultiPaper - CraftBukkit UUID to world map
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
@@ -1486,6 +1487,7 @@ public final class CraftServer implements Server {
this.getLogger().log(Level.SEVERE, null, ex);
}
+ this.worldsByUUID.remove(world.getUID()); // Gale - MultiPaper - CraftBukkit UUID to world map
this.worlds.remove(world.getName().toLowerCase(Locale.ROOT));
this.console.removeLevel(handle);
return true;
@@ -1504,12 +1506,7 @@ public final class CraftServer implements Server {
@Override
public World getWorld(UUID uid) {
- for (World world : this.worlds.values()) {
- if (world.getUID().equals(uid)) {
- return world;
- }
- }
- return null;
+ return this.worldsByUUID.get(uid); // Gale - MultiPaper - CraftBukkit UUID to world map
}
@Override
@@ -1525,6 +1522,7 @@ public final class CraftServer implements Server {
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;
}
+ this.worldsByUUID.put(world.getUID(), world); // Gale - MultiPaper - CraftBukkit UUID to world map
this.worlds.put(world.getName().toLowerCase(Locale.ROOT), world);
}