9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/server/0027-Optimize-CraftServer.getWorld-UUID.patch
Artem Ostrasev 774a111315 [ci-skip] New patches and optimisations (#11)
I'll make some changes now, so skipping build

Changelog:

* add CarpetFixes optimizations

* fix optimizations config

* lithium optimizations

* add Carpet Fixes Sheep Optimization

* add Async Pathfinding; add C2ME opts math

* add 2 vmp patches

* New performance patches; update README and wiki README

* update configuration on wiki

* update wiki main page

* Updated Upstream (Purpur)

* fix conflicts

* make "Don't save Fireworks" patch configurable

* Disable memory reserve allocating

* Fix MC-172801

* resolve conflicts

* add bstats to readme

* dd custom list of forks

* update logo link
2024-02-11 15:04:54 +03:00

53 lines
2.9 KiB
Diff

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 070a5ff6e16aa9f316489f7a1b812d84da2f6a60..63002b42a817bccda5a1587f8d349b38ebbf7c4d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,6 +264,8 @@ import net.md_5.bungee.api.chat.BaseComponent; // Spigot
import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // DivineMC
+
public final class CraftServer implements Server {
private final String serverName = "DivineMC"; // Paper // Pufferfish // Purpur // DivineMC
private final String serverVersion;
@@ -280,6 +282,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 Map<UUID, World> worldsByUUID = new Object2ObjectLinkedOpenHashMap<>(); // DivineMC - MultiPaper - optimize getWorld(UUID)
private final Map<Class<?>, Registry<?>> registries = new HashMap<>();
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
@@ -1465,6 +1468,7 @@ public final class CraftServer implements Server {
this.getLogger().log(Level.SEVERE, null, ex);
}
+ this.worldsByUUID.remove(world.getUID()); // DivineMC - MultiPaper - optimize getWorld(UUID)
this.worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH));
this.console.removeLevel(handle);
return true;
@@ -1483,6 +1487,7 @@ public final class CraftServer implements Server {
@Override
public World getWorld(UUID uid) {
+ if (true) return this.worldsByUUID.get(uid); // DivineMC - MultiPaper - optimize getWorld(UUID)
for (World world : this.worlds.values()) {
if (world.getUID().equals(uid)) {
return world;
@@ -1506,6 +1511,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); // DivineMC - MultiPaper - optimize getWorld(UUID)
this.worlds.put(world.getName().toLowerCase(java.util.Locale.ENGLISH), world);
}