mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-21 07:49:22 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@3b9db2b Updated Upstream (Bukkit/CraftBukkit) (#11501) PaperMC/Paper@c13f9fd Fix potential annotation testing interruption (#11460) PaperMC/Paper@260c3bb Always send Banner patterns to the client (#11506) PaperMC/Paper@14a48cd Some small touchups to the GUI (#11505) PaperMC/Paper@d348cb8 Restrict BlockProjectileSource#launchProjectile
67 lines
3.2 KiB
Diff
67 lines
3.2 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 84b8de571361f2087ac5106726c9e69377183089..9261f0ff637213a385fd518524702e777a4bb692 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -41,6 +41,9 @@ import java.util.logging.Logger;
|
|
import java.util.stream.Collectors;
|
|
import javax.imageio.ImageIO;
|
|
// import jline.console.ConsoleReader;
|
|
+
|
|
+import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
|
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|
import net.minecraft.advancements.AdvancementHolder;
|
|
import net.minecraft.commands.CommandSourceStack;
|
|
import net.minecraft.commands.Commands;
|
|
@@ -281,6 +284,7 @@ public final class CraftServer implements Server {
|
|
protected final DedicatedServer console;
|
|
protected final DedicatedPlayerList playerList;
|
|
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
|
|
+ private final Object2ObjectMap<UUID, World> worldsByUUID = new Object2ObjectOpenHashMap<>(); // Gale - MultiPaper - CraftBukkit UUID to world map
|
|
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
|
|
private YamlConfiguration configuration;
|
|
private YamlConfiguration commandsConfiguration;
|
|
@@ -1493,6 +1497,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;
|
|
@@ -1511,12 +1516,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
|
|
}
|
|
|
|
// Paper start
|
|
@@ -1534,6 +1534,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);
|
|
}
|
|
|