mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-24 01:09:27 +00:00
CraftBukkit UUID to world map
This commit is contained in:
66
patches/server/0107-CraftBukkit-UUID-to-world-map.patch
Normal file
66
patches/server/0107-CraftBukkit-UUID-to-world-map.patch
Normal file
@@ -0,0 +1,66 @@
|
||||
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 3107642e3e0888ff599e89ca21dd5f2c8b152448..3553b7cbbbcc2aff07be6bdcfbfceb8044675d77 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -48,6 +48,9 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.imageio.ImageIO;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
@@ -275,6 +278,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<>();
|
||||
private YamlConfiguration configuration;
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
@@ -1342,6 +1346,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(java.util.Locale.ENGLISH));
|
||||
this.console.removeLevel(handle);
|
||||
return true;
|
||||
@@ -1360,12 +1365,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
|
||||
@@ -1383,6 +1383,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(java.util.Locale.ENGLISH), world);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 3107642e3e0888ff599e89ca21dd5f2c8b152448..52e6d550d1e761dfbb45bced098d4bed30dc5bdb 100644
|
||||
index 3553b7cbbbcc2aff07be6bdcfbfceb8044675d77..ec1b0178a7c6d12e79cdbd4e52bd22613f8af7eb 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2731,6 +2731,25 @@ public final class CraftServer implements Server {
|
||||
@@ -2732,6 +2732,25 @@ public final class CraftServer implements Server {
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ index 81bb87b729f20be8ca4e5be0c2f5b1b6c1ce4422..1d45eefe9c791b742946cb162b0a7358
|
||||
tps5.add(currentTps, diff);
|
||||
tps15.add(currentTps, diff);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 52e6d550d1e761dfbb45bced098d4bed30dc5bdb..c36ad6c7681afdf9cb022b556d82f78f987c0f22 100644
|
||||
index ec1b0178a7c6d12e79cdbd4e52bd22613f8af7eb..cba623f82835e189ec615948c939ce4e4c690215 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2733,6 +2733,13 @@ public final class CraftServer implements Server {
|
||||
@@ -2734,6 +2734,13 @@ public final class CraftServer implements Server {
|
||||
|
||||
// Gale start - specific interval TPS API
|
||||
|
||||
@@ -23,10 +23,10 @@ The above copyright notice and this permission notice shall be included in all c
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index c36ad6c7681afdf9cb022b556d82f78f987c0f22..959294ff90db8806b1a114b3a6fe365b317a157b 100644
|
||||
index cba623f82835e189ec615948c939ce4e4c690215..b9a799997e3475117ab91d7f3edb5f2f243a9f6b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2980,4 +2980,22 @@ public final class CraftServer implements Server {
|
||||
@@ -2981,4 +2981,22 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
// Paper end
|
||||
@@ -32,10 +32,10 @@ index f5ed3fa20097bdd43a25c76b38353a23743bc9e5..eed9f125df46b616b7234a2d669971bc
|
||||
// Attempt to detect vectorization
|
||||
try {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 959294ff90db8806b1a114b3a6fe365b317a157b..404a0469cdb8b6b1c37e348e1b8a59f89f7469d2 100644
|
||||
index b9a799997e3475117ab91d7f3edb5f2f243a9f6b..e23fdd5ba09b50b7eef0ca4f36c5480779fba624 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -251,6 +251,8 @@ import org.bukkit.scoreboard.Criteria;
|
||||
@@ -254,6 +254,8 @@ import org.bukkit.scoreboard.Criteria;
|
||||
import org.bukkit.structure.StructureManager;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.bukkit.util.permissions.DefaultPermissions;
|
||||
@@ -1736,10 +1736,10 @@ index 9948cc4c65d5681c171b38cdf7cf3e63a01e4364..c37793871951b0044168610bc05ee052
|
||||
final Entity entity = level.getEntity(this.ownerUUID);
|
||||
if (entity != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 404a0469cdb8b6b1c37e348e1b8a59f89f7469d2..68ea5eff62875732a0d276d96d39a5b2494df964 100644
|
||||
index e23fdd5ba09b50b7eef0ca4f36c5480779fba624..79f3a6174873834de61d7dc9fdbf6eb5a0fd6cd9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -982,7 +982,7 @@ public final class CraftServer implements Server {
|
||||
@@ -986,7 +986,7 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration
|
||||
@@ -1748,7 +1748,7 @@ index 404a0469cdb8b6b1c37e348e1b8a59f89f7469d2..68ea5eff62875732a0d276d96d39a5b2
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
|
||||
@@ -1166,7 +1166,7 @@ public final class CraftServer implements Server {
|
||||
@@ -1170,7 +1170,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public World createWorld(WorldCreator creator) {
|
||||
@@ -1757,7 +1757,7 @@ index 404a0469cdb8b6b1c37e348e1b8a59f89f7469d2..68ea5eff62875732a0d276d96d39a5b2
|
||||
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
|
||||
Validate.notNull(creator, "Creator may not be null");
|
||||
|
||||
@@ -2525,7 +2525,7 @@ public final class CraftServer implements Server {
|
||||
@@ -2526,7 +2526,7 @@ public final class CraftServer implements Server {
|
||||
public Entity getEntity(UUID uuid) {
|
||||
Validate.notNull(uuid, "UUID cannot be null");
|
||||
|
||||
Reference in New Issue
Block a user