Skip to content

Commit 312de96

Browse files
committed
Finish world key initial migration
1 parent a8c05a3 commit 312de96

22 files changed

Lines changed: 134 additions & 130 deletions

paper-api/src/main/java/co/aikar/timings/TimingHistory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public JSONPair apply(World world) {
134134
}
135135
}
136136
return pair(
137-
worldMap.get(world.getKey().toString()),
137+
worldMap.get(world.key().asString()),
138138
toArrayMapper(regions.values(),new Function<RegionData, Object>() {
139139
@NotNull
140140
@Override

paper-api/src/main/java/org/bukkit/Bukkit.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,13 @@ public static boolean unloadWorld(@NotNull World world, boolean save) {
857857
}
858858

859859
/**
860-
* Gets the world with the given name.
860+
* Gets the world with the given legacy Bukkit name.
861861
*
862862
* <p>This method is considered obsolete and is a candidate for future deprecation.
863863
* Prefer using {@link #getWorld(NamespacedKey)}.</p>
864864
*
865-
* @param name the name of the world to retrieve
866-
* @return a world with the given name, or null if none exists
865+
* @param name the legacy Bukkit name of the world to retrieve
866+
* @return a world with the given legacy Bukkit name, or null if none exists
867867
*/
868868
@ApiStatus.Obsolete
869869
@Nullable

paper-api/src/main/java/org/bukkit/Location.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package org.bukkit;
22

33
import com.google.common.base.Preconditions;
4+
import io.papermc.paper.math.FinePosition;
5+
import io.papermc.paper.math.Rotation;
46
import java.lang.ref.Reference;
57
import java.lang.ref.WeakReference;
68
import java.util.Collection;
79
import java.util.HashMap;
810
import java.util.Map;
911
import java.util.function.Predicate;
10-
import io.papermc.paper.math.FinePosition;
11-
import io.papermc.paper.math.Rotation;
1212
import org.bukkit.block.Block;
1313
import org.bukkit.configuration.serialization.ConfigurationSerializable;
1414
import org.bukkit.entity.Entity;
@@ -574,7 +574,7 @@ public double distanceSquared(@NotNull Location o) {
574574
} else if (o.getWorld() == null || getWorld() == null) {
575575
throw new IllegalArgumentException("Cannot measure distance to a null world");
576576
} else if (o.getWorld() != getWorld()) {
577-
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getKey() + " and " + o.getWorld().getKey());
577+
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().key().asString() + " and " + o.getWorld().key().asString());
578578
}
579579

580580
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
@@ -1186,10 +1186,11 @@ public static int locToBlock(double loc) {
11861186
@Utility
11871187
@NotNull
11881188
public Map<String, Object> serialize() {
1189-
Map<String, Object> data = new HashMap<String, Object>();
1189+
Map<String, Object> data = new HashMap<>();
11901190

1191-
if (this.world != null) {
1192-
data.put("world_key", getWorld().getKey().toString());
1191+
World world = this.getWorld();
1192+
if (world != null) {
1193+
data.put("world_key", world.key().asString());
11931194
}
11941195

11951196
data.put("x", this.x);
@@ -1219,15 +1220,15 @@ public static Location deserialize(@NotNull Map<String, Object> args) {
12191220
requiresWorld = true;
12201221
}
12211222
if (args.containsKey("world_key")) {
1222-
world = Bukkit.getWorld(NamespacedKey.fromString((String) args.get("world_key")));
1223+
NamespacedKey key = NamespacedKey.fromString((String) args.get("world_key"));
1224+
world = key == null ? null : Bukkit.getWorld(key);
12231225
requiresWorld = true;
12241226
}
12251227

12261228
if (requiresWorld && world == null) {
12271229
throw new IllegalArgumentException("unknown world");
12281230
}
12291231

1230-
12311232
return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch")));
12321233
}
12331234

paper-server/patches/features/0001-Moonrise-optimisation-patches.patch

Lines changed: 52 additions & 48 deletions
Large diffs are not rendered by default.

paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,10 +2352,10 @@ index 26c05173e7fb2bf055afda1717af0dd2e997118d..ffe3ae41dd3d8c4141f81edf0b92001d
23522352
return toLevel.dimension() != Level.NETHER || this.getGameRules().get(GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS);
23532353
}
23542354
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
2355-
index 31c7223d2d01573c24d4ad83737fa2c2752db028..8df070a7135411806d42ea692b566c4d8389a47b 100644
2355+
index 10c90af8d7edcc79183da04d0d90efb8d4b6a50d..dcf38378f4e51af9558d1ffc72564dc7410cf56b 100644
23562356
--- a/net/minecraft/world/level/Level.java
23572357
+++ b/net/minecraft/world/level/Level.java
2358-
@@ -2152,6 +2152,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
2358+
@@ -2153,6 +2153,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
23592359
return this.palettedContainerFactory;
23602360
}
23612361

paper-server/patches/features/0020-Incremental-chunk-and-player-saving.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving
55

66

77
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
8-
index 40a500011e7fcb6f5b07ff289f737ed9d3550296..da8c04aa02032c4c582709727f8f7f0b66b697b1 100644
8+
index feadfc4aa5beb306e4df25f810e9dcea1a400fd6..7767838df2946583751a7d078e7a5dcf0d90ff58 100644
99
--- a/net/minecraft/server/MinecraftServer.java
1010
+++ b/net/minecraft/server/MinecraftServer.java
11-
@@ -958,7 +958,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
11+
@@ -968,7 +968,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
1212
}
1313
public boolean saveAllChunks(final boolean silent, final boolean flush, final boolean force, final boolean close) {
1414
// Paper end - add close param
@@ -17,7 +17,7 @@ index 40a500011e7fcb6f5b07ff289f737ed9d3550296..da8c04aa02032c4c582709727f8f7f0b
1717
boolean result = false;
1818

1919
for (ServerLevel level : this.getAllLevels()) {
20-
@@ -970,13 +970,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
20+
@@ -980,13 +980,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2121
result = true;
2222
}
2323

@@ -32,7 +32,7 @@ index 40a500011e7fcb6f5b07ff289f737ed9d3550296..da8c04aa02032c4c582709727f8f7f0b
3232

3333
if (flush) {
3434
for (ServerLevel level : this.getAllLevels()) {
35-
@@ -990,11 +984,25 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
35+
@@ -1000,11 +994,25 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
3636
return result;
3737
}
3838

@@ -59,7 +59,7 @@ index 40a500011e7fcb6f5b07ff289f737ed9d3550296..da8c04aa02032c4c582709727f8f7f0b
5959
boolean result = this.saveAllChunks(silent, flush, force);
6060
this.warnOnLowDiskSpace();
6161
var5 = result;
62-
@@ -1641,9 +1649,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
62+
@@ -1651,9 +1659,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
6363
}
6464

6565
this.ticksUntilAutosave--;

paper-server/patches/features/0025-Optimise-EntityScheduler-ticking.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ index 2bc436cdf5180a7943c45fabb9fbbedae6f7db56..f312a7f5b1b2a777ab36b94ce7cbf387
2020

2121
@Override
2222
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
23-
index da8c04aa02032c4c582709727f8f7f0b66b697b1..3923f21c67165e2ecd2c9cecd5266758435a6806 100644
23+
index 7767838df2946583751a7d078e7a5dcf0d90ff58..893e651e6aaf02a6877cc1335a3f73b8fada7cc9 100644
2424
--- a/net/minecraft/server/MinecraftServer.java
2525
+++ b/net/minecraft/server/MinecraftServer.java
26-
@@ -1784,32 +1784,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
26+
@@ -1794,32 +1794,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2727
}
2828
}
2929

paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ index d2877c20f389d0131e1dd208b464f590671e5d82..27bdc70d861ca39487ad16cb3afb89d6
4242
updateComponent(root, "minecraft:trim", hiddenComponents);
4343
updateComponent(root, "minecraft:unbreakable", hiddenComponents);
4444
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
45-
index ae140a514e1e3200f52c5933f886cc9e820b818a..4a1146cc54bd9272466ffc9bb64f600c40f0c0f4 100644
45+
index 80162ffef5d54d00663dcb58a087884ec8a3eaaa..fe6e148322e920989ac3ffc3c10de95d782265f9 100644
4646
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
4747
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
4848
@@ -1820,9 +1820,14 @@ public class ServerGamePacketListenerImpl
@@ -62,10 +62,10 @@ index ae140a514e1e3200f52c5933f886cc9e820b818a..4a1146cc54bd9272466ffc9bb64f600c
6262
);
6363

6464
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
65-
index 8df070a7135411806d42ea692b566c4d8389a47b..06451a21c4bfbcd95063f96246013d63f65af8a3 100644
65+
index dcf38378f4e51af9558d1ffc72564dc7410cf56b..829bb616e5d72b955248bbc150254c239176ce64 100644
6666
--- a/net/minecraft/world/level/Level.java
6767
+++ b/net/minecraft/world/level/Level.java
68-
@@ -1528,7 +1528,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
68+
@@ -1529,7 +1529,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
6969
if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups)
7070
return false;
7171
// Paper start - optimise collisions

paper-server/patches/features/0029-Optimize-Hoppers.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf
4848
+ }
4949
+}
5050
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
51-
index 3923f21c67165e2ecd2c9cecd5266758435a6806..92acd256fdf815dfb8dd743cf8ecd0eb377d996e 100644
51+
index 893e651e6aaf02a6877cc1335a3f73b8fada7cc9..307cf457a909e93ce20af5b272041c2c7aa75c0c 100644
5252
--- a/net/minecraft/server/MinecraftServer.java
5353
+++ b/net/minecraft/server/MinecraftServer.java
54-
@@ -1836,6 +1836,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
54+
@@ -1846,6 +1846,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
5555
level.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
5656
level.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
5757
level.updateLagCompensationTick(); // Paper - lag compensation

paper-server/patches/features/0030-Anti-Xray.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ index a94e6ca1d396b6b0781de5d550c4a804274ee003..a1018e9ca9dfb978d6e6633577abd7d5
155155

156156
private ClientboundLevelChunkWithLightPacket(final RegistryFriendlyByteBuf input) {
157157
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
158-
index 78021db10860396fef4eb2e01926fbad123916fa..3f02da2014ed8e4169f4bb819b4d9e61154b7b06 100644
158+
index 98461e8468a7eeaef2544ee907ff64de1fd42a49..d1844172dda959ade0bc64e2b2621f0f61086c44 100644
159159
--- a/net/minecraft/server/level/ServerLevel.java
160160
+++ b/net/minecraft/server/level/ServerLevel.java
161161
@@ -630,7 +630,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
@@ -209,7 +209,7 @@ index b69bcaa1e27a4fbe9a9568f3c9e1843167abe1f5..9218322801c41657c00928ef90b0de99
209209
}
210210
// Paper end - Send empty chunk
211211
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
212-
index 06451a21c4bfbcd95063f96246013d63f65af8a3..e34e901dce06c6bc6060418593010dcfb38e9396 100644
212+
index 829bb616e5d72b955248bbc150254c239176ce64..4b228b5c563e40b6f301df22b5c8a7f7988cb072 100644
213213
--- a/net/minecraft/world/level/Level.java
214214
+++ b/net/minecraft/world/level/Level.java
215215
@@ -145,6 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -230,15 +230,15 @@ index 06451a21c4bfbcd95063f96246013d63f65af8a3..e34e901dce06c6bc6060418593010dcf
230230
) {
231231
// Paper start - getblock optimisations - cache world height/sections
232232
final DimensionType dimType = dimensionTypeRegistration.value();
233-
@@ -870,6 +872,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
233+
@@ -871,6 +873,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
234234
this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess);
235235
this.damageSources = new DamageSources(registryAccess);
236236
this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system
237237
+ this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
238238
}
239239

240240
// Paper start - Cancel hit for vanished players
241-
@@ -1084,6 +1087,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
241+
@@ -1085,6 +1088,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
242242
}
243243
// CraftBukkit end - capture blockstates
244244
BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags);

0 commit comments

Comments
 (0)