diff --git a/paper-api/src/main/java/co/aikar/timings/TimingHistory.java b/paper-api/src/main/java/co/aikar/timings/TimingHistory.java index 19bb744a4d89..89bd9555d0c9 100644 --- a/paper-api/src/main/java/co/aikar/timings/TimingHistory.java +++ b/paper-api/src/main/java/co/aikar/timings/TimingHistory.java @@ -134,7 +134,7 @@ public JSONPair apply(World world) { } } return pair( - worldMap.get(world.getKey().toString()), + worldMap.get(world.key().asString()), toArrayMapper(regions.values(),new Function() { @NotNull @Override diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 5ab8f0d77bbf..de21023e1e0e 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -857,13 +857,13 @@ public static boolean unloadWorld(@NotNull World world, boolean save) { } /** - * Gets the world with the given name. + * Gets the world with the given legacy Bukkit name. * *

This method is considered obsolete and is a candidate for future deprecation. * Prefer using {@link #getWorld(NamespacedKey)}.

* - * @param name the name of the world to retrieve - * @return a world with the given name, or null if none exists + * @param name the legacy Bukkit name of the world to retrieve + * @return a world with the given legacy Bukkit name, or null if none exists */ @ApiStatus.Obsolete @Nullable diff --git a/paper-api/src/main/java/org/bukkit/Location.java b/paper-api/src/main/java/org/bukkit/Location.java index 43f2a5661f53..1a89e738b792 100644 --- a/paper-api/src/main/java/org/bukkit/Location.java +++ b/paper-api/src/main/java/org/bukkit/Location.java @@ -1,14 +1,14 @@ package org.bukkit; import com.google.common.base.Preconditions; +import io.papermc.paper.math.FinePosition; +import io.papermc.paper.math.Rotation; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; -import io.papermc.paper.math.FinePosition; -import io.papermc.paper.math.Rotation; import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.entity.Entity; @@ -574,7 +574,7 @@ public double distanceSquared(@NotNull Location o) { } else if (o.getWorld() == null || getWorld() == null) { throw new IllegalArgumentException("Cannot measure distance to a null world"); } else if (o.getWorld() != getWorld()) { - throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getKey() + " and " + o.getWorld().getKey()); + throw new IllegalArgumentException("Cannot measure distance between " + getWorld().key().asString() + " and " + o.getWorld().key().asString()); } 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) { @Utility @NotNull public Map serialize() { - Map data = new HashMap(); + Map data = new HashMap<>(); - if (this.world != null) { - data.put("world_key", getWorld().getKey().toString()); + World world = this.getWorld(); + if (world != null) { + data.put("world_key", world.key().asString()); } data.put("x", this.x); @@ -1219,7 +1220,8 @@ public static Location deserialize(@NotNull Map args) { requiresWorld = true; } if (args.containsKey("world_key")) { - world = Bukkit.getWorld(NamespacedKey.fromString((String) args.get("world_key"))); + NamespacedKey key = NamespacedKey.fromString((String) args.get("world_key")); + world = key == null ? null : Bukkit.getWorld(key); requiresWorld = true; } @@ -1227,7 +1229,6 @@ public static Location deserialize(@NotNull Map args) { throw new IllegalArgumentException("unknown world"); } - 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"))); } diff --git a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch index ca34837aaefb..2f5fc143544b 100644 --- a/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0001-Moonrise-optimisation-patches.patch @@ -23277,10 +23277,10 @@ index 1cd5901c8e4eb4114ab347a393fc37095c8642d2..fadce1c051e6c7bc0c3d041c0cc8ecd7 +} diff --git a/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9b89a6fb3 +index 0000000000000000000000000000000000000000..d86bd11e0155f767c3bf66ac05fa4acf6d2bfccb --- /dev/null +++ b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java -@@ -0,0 +1,277 @@ +@@ -0,0 +1,269 @@ +package io.papermc.paper.command.subcommands; + +import ca.spottedleaf.moonrise.common.util.JsonUtil; @@ -23301,6 +23301,8 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.ProtoChunk; +import org.bukkit.Bukkit; ++import org.bukkit.NamespacedKey; ++import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.CraftWorld; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -23327,44 +23329,33 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + + @Override + public List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { -+ switch (subCommand) { -+ case "debug" -> { -+ if (args.length == 1) { -+ return CommandUtil.getListMatchingLast(sender, args, "help", "chunks"); -+ } -+ } -+ case "holderinfo" -> { -+ List worldNames = new ArrayList<>(); -+ worldNames.add("*"); -+ for (org.bukkit.World world : Bukkit.getWorlds()) { -+ worldNames.add(world.getKey().toString()); -+ } -+ if (args.length == 1) { -+ return CommandUtil.getListMatchingLast(sender, args, worldNames); -+ } -+ } -+ case "chunkinfo" -> { -+ List worldNames = new ArrayList<>(); -+ worldNames.add("*"); -+ for (org.bukkit.World world : Bukkit.getWorlds()) { -+ worldNames.add(world.getKey().toString()); -+ } ++ return switch (subCommand) { ++ case "debug": + if (args.length == 1) { -+ return CommandUtil.getListMatchingLast(sender, args, worldNames); ++ yield CommandUtil.getListMatchingLast(sender, args, "help", "chunks"); ++ } ++ case "chunkinfo", "holderinfo": ++ if (args.length >= 1 && (args.length == 1 || !args[0].equals("*"))) { ++ yield CommandUtil.getListMatchingLast( ++ sender, ++ args, ++ CommandUtil.getWorldSuggestions(sender.getServer(), args.length == 1) ++ ); + } -+ } -+ } -+ return Collections.emptyList(); ++ default: ++ yield Collections.emptyList(); ++ }; + } + + private void doChunkInfo(final CommandSender sender, final String[] args) { -+ List worlds; ++ List worlds; + if (args.length < 1 || args[0].equals("*")) { -+ worlds = Bukkit.getWorlds(); ++ worlds = Bukkit.getServer().getWorlds(); + } else { + worlds = new ArrayList<>(args.length); + for (final String arg : args) { -+ org.bukkit.@Nullable World world = Bukkit.getWorld(arg); ++ @Nullable NamespacedKey key = NamespacedKey.fromString(arg); ++ @Nullable World world = key == null ? null : sender.getServer().getWorld(key); + if (world == null) { + sender.sendMessage(text("World '" + arg + "' is invalid", RED)); + return; @@ -23379,7 +23370,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + int accumulatedTicking = 0; + int accumulatedEntityTicking = 0; + -+ for (final org.bukkit.World bukkitWorld : worlds) { ++ for (final World bukkitWorld : worlds) { + final ServerLevel world = ((CraftWorld) bukkitWorld).getHandle(); + + int total = 0; @@ -23390,7 +23381,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + + for (final NewChunkHolder holder : ((ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolders()) { + final NewChunkHolder.ChunkCompletion completion = holder.getLastChunkCompletion(); -+ final ChunkAccess chunk = completion == null ? null : completion.chunk(); ++ final @Nullable ChunkAccess chunk = completion == null ? null : completion.chunk(); + + if (!(chunk instanceof LevelChunk fullChunk)) { + continue; @@ -23424,7 +23415,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + accumulatedTicking += blockTicking; + accumulatedEntityTicking += entityTicking; + -+ sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key().toString(), GREEN), text(":"))); ++ sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key().asString(), GREEN), text(":"))); + sender.sendMessage(text().color(DARK_AQUA).append( + text("Total: ", BLUE), text(total), + text(" Inactive: ", BLUE), text(inactive), @@ -23446,13 +23437,14 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + } + + private void doHolderInfo(final CommandSender sender, final String[] args) { -+ List worlds; ++ List worlds; + if (args.length < 1 || args[0].equals("*")) { -+ worlds = Bukkit.getWorlds(); ++ worlds = Bukkit.getServer().getWorlds(); + } else { + worlds = new ArrayList<>(args.length); + for (final String arg : args) { -+ org.bukkit.@Nullable World world = Bukkit.getWorld(arg); ++ @Nullable NamespacedKey key = NamespacedKey.fromString(arg); ++ @Nullable World world = key == null ? null : sender.getServer().getWorld(key); + if (world == null) { + sender.sendMessage(text("World '" + arg + "' is invalid", RED)); + return; @@ -23468,7 +23460,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + int accumulatedProtoChunk = 0; + int accumulatedFullChunk = 0; + -+ for (final org.bukkit.World bukkitWorld : worlds) { ++ for (final World bukkitWorld : worlds) { + final ServerLevel world = ((CraftWorld) bukkitWorld).getHandle(); + + int total = 0; @@ -23480,7 +23472,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + + for (final NewChunkHolder holder : ((ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolders()) { + final NewChunkHolder.ChunkCompletion completion = holder.getLastChunkCompletion(); -+ final ChunkAccess chunk = completion == null ? null : completion.chunk(); ++ final @Nullable ChunkAccess chunk = completion == null ? null : completion.chunk(); + + ++total; + @@ -23506,7 +23498,7 @@ index 0000000000000000000000000000000000000000..09f1a74740f898559edc8892ae59aca9 + accumulatedProtoChunk += protoChunk; + accumulatedFullChunk += fullChunk; + -+ sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.getKey().toString(), GREEN), text(":"))); ++ sender.sendMessage(text().append(text("Chunks in ", BLUE), text(bukkitWorld.key().asString(), GREEN), text(":"))); + sender.sendMessage(text().color(DARK_AQUA).append( + text("Total: ", BLUE), text(total), + text(" Unloadable: ", BLUE), text(canUnload), @@ -23838,7 +23830,7 @@ index 3c1490ac7c259da04031db2f170e0c0a5f512191..470d7c770ae9d045b97e2df145cfe3cf } } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index aebc47b0ed5c5a47b3e70e0c94ab5f7abaca523d..7c6a23408d7fe9cb11891678af97b5b7761d6bbc 100644 +index d22f55c63eb950e1b979280612eb9f155e986406..93690b360e5eb1b8d2f8ab2198aa087c9be7ffe2 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -191,7 +191,7 @@ import net.minecraft.world.scores.ScoreboardSaveData; @@ -30053,7 +30045,7 @@ index e07a7bda45146686a6ac2d20507df9fc8630514f..f84e651e2a34e76a0a71993332e4be1b // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb06be81da 100644 +index 838bad640b7f8e42fc8972918cfc7c1d9807e2b3..c0f901c4ac61a0aa2b480f102feb3669b111f4c0 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -87,6 +87,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -30725,10 +30717,10 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb + this.maxSectionY = this.maxY >> 4; + this.sectionsCount = this.maxSectionY - this.minSectionY + 1; + // Paper end - getblock optimisations - cache world height/sections - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, CraftNamespacedKey.fromMinecraft(dimension.identifier())); // Spigot + final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config - this.generator = generator; -@@ -230,6 +863,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -231,6 +864,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.registryAccess = registryAccess; this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); @@ -30736,7 +30728,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb } // Paper start - Cancel hit for vanished players -@@ -511,7 +1145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -512,7 +1146,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.setBlocksDirty(pos, blockState, blockState1); } @@ -30745,7 +30737,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb this.sendBlockUpdated(pos, blockState, state, flags); } -@@ -845,6 +1479,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -846,6 +1480,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper - Fix MC-117075 use removeAll - remove iterator in favour of indexed for loop, ensuring compile error if something uses iter incorrectly boolean tickBlockEntities = this.tickRateManager().runsNormally(); @@ -30753,7 +30745,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb // Paper start - Fix MC-117075 use removeAll final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<@Nullable TickingBlockEntity> toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); toRemove.add(null); -@@ -855,6 +1490,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -856,6 +1491,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { toRemove.add(ticker); // Paper - Fix MC-117075 use removeAll } else if (tickBlockEntities && this.shouldTickBlocksAt(ticker.getPos())) { ticker.tick(); @@ -30765,7 +30757,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb } } -@@ -873,6 +1513,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -874,6 +1514,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -30773,7 +30765,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -880,7 +1521,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -881,7 +1522,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public boolean noCollision(@Nullable Entity entity, AABB box) { if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; @@ -30789,7 +30781,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -1025,7 +1673,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1026,7 +1674,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isInValidBounds(pos)) { return null; } else { @@ -30798,7 +30790,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1105,20 +1753,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1106,20 +1754,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(final @Nullable Entity except, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("getEntities"); @@ -30826,7 +30818,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb } @Override -@@ -1134,33 +1777,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1135,33 +1778,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.getEntities(type, bb, selector, output, Integer.MAX_VALUE); } @@ -30941,7 +30933,7 @@ index 2fd4e73ed16d2d11267156840d7d9859d040317e..b8d56c7a14521cb77ba2cf619be826fb public boolean hasEntities(final EntityTypeTest type, final AABB bb, final Predicate selector) { Profiler.get().incrementCounter("hasEntities"); -@@ -1465,13 +2169,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1466,13 +2170,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper start - allow patching this logic public final int getEntityCount() { diff --git a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch index 59deb04af574..148a48e14e03 100644 --- a/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0016-Add-Alternate-Current-redstone-implementation.patch @@ -2355,7 +2355,7 @@ diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Le index 2b3ec0a012918815ed0eda8b40647c2274a5b418..e60717b486756f66660e88055eea0f4735f351ef 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2152,6 +2152,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2153,6 +2153,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.palettedContainerFactory; } diff --git a/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch b/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch index 75830611c7a5..27476bd810ce 100644 --- a/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch +++ b/paper-server/patches/features/0024-Improve-keepalive-ping-system.patch @@ -117,7 +117,7 @@ index d87a00ee3cd04ce25dbe46ae6b386b7f0799102c..ace440c2b82a6368aa27a85ff433ba2c } } diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index abeca4714053fd0a4fa489d496e2e0b844de40a8..0d5bf5b8b3fa23dfa6fe9acf54582fcec6f94496 100644 +index abeca4714053fd0a4fa489d496e2e0b844de40a8..7ed50fc00c58c7781c958df1d828a67adf696f3e 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -39,12 +39,13 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -234,11 +234,12 @@ index abeca4714053fd0a4fa489d496e2e0b844de40a8..0d5bf5b8b3fa23dfa6fe9acf54582fce } } -@@ -420,6 +447,14 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -420,6 +447,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } protected CommonListenerCookie createCookie(final ClientInformation clientInformation) { - return new CommonListenerCookie(this.playerProfile(), this.latency, clientInformation, this.transferred, this.playerBrand, this.pluginMessagerChannels); // Paper ++ // Paper start - listener handoff should reset pending keepalive expectations + return new CommonListenerCookie( + this.playerProfile(), + this.latency, @@ -247,6 +248,7 @@ index abeca4714053fd0a4fa489d496e2e0b844de40a8..0d5bf5b8b3fa23dfa6fe9acf54582fce + this.playerBrand, + this.pluginMessagerChannels, + this.keepAlive.copyForListenerHandoff() -+ ); // Paper - listener handoff should reset pending keepalive expectations ++ ); ++ // Paper end - listener handoff should reset pending keepalive expectations } } diff --git a/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch b/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch index 97d02b3001ea..900a854dba73 100644 --- a/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch +++ b/paper-server/patches/features/0026-DataConverter-Moonrise-co-fixes.patch @@ -65,7 +65,7 @@ diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Le index fa3809be5c0488c5a1d2639579d68619b0a55de9..c332d48f5cac2f3be93201c66f4f7cdba916cbac 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1528,7 +1528,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1529,7 +1529,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; // Paper start - optimise collisions diff --git a/paper-server/patches/features/0030-Anti-Xray.patch b/paper-server/patches/features/0030-Anti-Xray.patch index f828830ec388..7ad1ed261c1d 100644 --- a/paper-server/patches/features/0030-Anti-Xray.patch +++ b/paper-server/patches/features/0030-Anti-Xray.patch @@ -209,7 +209,7 @@ index 5e11abcfd681d86b1c0e282cf901108822766ce2..3020a3208b14bb483b08cf59a796fb83 } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 06451a21c4bfbcd95063f96246013d63f65af8a3..e34e901dce06c6bc6060418593010dcfb38e9396 100644 +index 829bb616e5d72b955248bbc150254c239176ce64..4b228b5c563e40b6f301df22b5c8a7f7988cb072 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -145,6 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -230,7 +230,7 @@ index 06451a21c4bfbcd95063f96246013d63f65af8a3..e34e901dce06c6bc6060418593010dcf ) { // Paper start - getblock optimisations - cache world height/sections final DimensionType dimType = dimensionTypeRegistration.value(); -@@ -870,6 +872,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -871,6 +873,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.palettedContainerFactory = PalettedContainerFactory.create(registryAccess); this.damageSources = new DamageSources(registryAccess); this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system @@ -238,7 +238,7 @@ index 06451a21c4bfbcd95063f96246013d63f65af8a3..e34e901dce06c6bc6060418593010dcf } // Paper start - Cancel hit for vanished players -@@ -1084,6 +1087,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1085,6 +1088,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // CraftBukkit end - capture blockstates BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags); diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index dbfb75d16abb..73dcdaec0643 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -501,9 +501,9 @@ + java.util.Random rand = new java.util.Random(level.getSeed()); + org.bukkit.Location spawn = level.generator.getFixedSpawnLocation(level.getWorld(), rand); + -+ if (spawn != null) { ++ if (spawn != null && spawn.getWorld() != null) { + if (spawn.getWorld() != level.getWorld()) { -+ throw new IllegalStateException("Cannot set spawn point for " + levelData.getLevelName() + " to be in another world (" + (spawn.getWorld() != null ? spawn.getWorld().key() : null) + ")"); ++ throw new IllegalStateException("Cannot set spawn point for " + levelData.getLevelName() + " to be in another world (" + spawn.getWorld().key().asString() + ")"); + } else { + levelData.setSpawn( + net.minecraft.world.level.storage.LevelData.RespawnData.of( diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index ac8e16984c4e..e51510437f3b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -76,7 +76,7 @@ protected Level( final WritableLevelData levelData, final ResourceKey dimension, -@@ -141,7 +_,24 @@ +@@ -141,7 +_,25 @@ final boolean isDebug, final long biomeZoomSeed, final int maxChainedNeighborUpdates @@ -87,10 +87,11 @@ + java.util.function.Function paperWorldConfigCreator // Paper - create paper world config ) { -+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, CraftNamespacedKey.fromMinecraft(dimension.identifier())); // Spigot ++ final org.bukkit.NamespacedKey worldKey = CraftNamespacedKey.fromMinecraft(dimension.identifier()); // Paper ++ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(bukkitName, worldKey); // Spigot + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.generator = generator; -+ this.world = new CraftWorld((ServerLevel) this, dimension.identifier(), biomeProvider, environment); ++ this.world = new CraftWorld((ServerLevel) this, worldKey, biomeProvider, environment); + + for (SpawnCategory spawnCategory : SpawnCategory.values()) { + if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { diff --git a/paper-server/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/paper-server/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java index 98b50db269f2..83ec0263aaed 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java @@ -71,7 +71,7 @@ public static JsonObject serialize() { final JsonObject worldData = new JsonObject(); - worldData.addProperty("name", world.getWorld().getKey().toString()); + worldData.addProperty("key", world.getWorld().key().asString()); final List> data = new ArrayList<>(); diff --git a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java index a9443f24971f..581c34fca6d0 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java +++ b/paper-server/src/main/java/io/papermc/paper/command/CommandUtil.java @@ -9,6 +9,8 @@ import java.util.Iterator; import java.util.List; import net.minecraft.resources.Identifier; +import org.bukkit.Server; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; @@ -18,6 +20,18 @@ public final class CommandUtil { private CommandUtil() { } + public static List getWorldSuggestions(Server server, boolean withWildcard) { + List worlds = server.getWorlds(); + List worldKeys = new ArrayList<>(worlds.size() + (withWildcard ? 1 : 0)); + if (withWildcard) { + worldKeys.add("*"); + } + for (World world : worlds) { + worldKeys.add(world.key().asString()); + } + return worldKeys; + } + // Code from Mojang - copyright them public static List getListMatchingLast( final CommandSender sender, diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java index 050662c995a8..a4212e9b0df5 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java @@ -4,7 +4,9 @@ import io.papermc.paper.FeatureHooks; import io.papermc.paper.command.CommandUtil; import io.papermc.paper.command.PaperSubcommand; +import io.papermc.paper.util.MCUtil; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -21,7 +23,6 @@ import net.minecraft.world.level.ChunkPos; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.bukkit.Bukkit; import org.bukkit.HeightMap; import org.bukkit.NamespacedKey; import org.bukkit.World; @@ -48,8 +49,12 @@ public boolean execute(final CommandSender sender, final String subCommand, fina public List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { if (args.length == 1) { return CommandUtil.getListMatchingLast(sender, args, "help", "list"); - } else if (args.length == 2) { - return CommandUtil.getListMatchingLast(sender, args, BuiltInRegistries.ENTITY_TYPE.keySet()); + } else if (args.length > 1 && args[0].toLowerCase(Locale.ROOT).equals("list")) { + if (args.length == 2) { + return CommandUtil.getListMatchingLast(sender, args, BuiltInRegistries.ENTITY_TYPE.keySet()); + } else if (args.length == 3) { + return CommandUtil.getListMatchingLast(sender, args, CommandUtil.getWorldSuggestions(sender.getServer(), false)); + } } return Collections.emptyList(); } @@ -60,58 +65,55 @@ public List tabComplete(final CommandSender sender, final String subComm private void listEntities(final CommandSender sender, final String[] args) { // help if (args.length < 1 || !args[0].toLowerCase(Locale.ROOT).equals("list")) { - sender.sendMessage(text("Use /paper entity [list] help for more information on a specific command", RED)); + sender.sendMessage(text("Use /paper entity list [filter] [world] to get entity info that matches the optional filter.", RED)); return; } if ("list".equals(args[0].toLowerCase(Locale.ROOT))) { String filter = "*"; if (args.length > 1) { - if (args[1].toLowerCase(Locale.ROOT).equals("help")) { - sender.sendMessage(text("Use /paper entity list [filter] [worldName] to get entity info that matches the optional filter.", RED)); - return; - } filter = args[1]; } - final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?"); + final String cleanFilter = filter.replace("?", ".?").replace("*", ".*?"); Set names = BuiltInRegistries.ENTITY_TYPE.keySet().stream() - .filter(n -> n.toString().matches(cleanfilter)) + .filter(n -> n.toString().matches(cleanFilter)) .collect(Collectors.toSet()); if (names.isEmpty()) { sender.sendMessage(text("Invalid filter, does not match any entities. Use /paper entity list for a proper list", RED)); - sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED)); + sender.sendMessage(text("Usage: /paper entity list [filter] [world]", RED)); return; } - String worldName; + + final @Nullable World world; if (args.length > 2) { - worldName = args[2]; - } else if (sender instanceof Player) { - worldName = ((Player) sender).getWorld().getKey().toString(); + @Nullable NamespacedKey key = NamespacedKey.fromString(args[2]); + world = key == null ? null : sender.getServer().getWorld(key); + if (world == null) { + sender.sendMessage(text("Could not load world for " + args[2] + ". Please select a valid world.", RED)); + sender.sendMessage(text("Usage: /paper entity list [filter] [world]", RED)); + return; + } + } else if (sender instanceof Player player) { + world = player.getWorld(); } else { - sender.sendMessage(text("Please specify the name of a world", RED)); + sender.sendMessage(text("Please specify the key of a world", RED)); sender.sendMessage(text("To do so without a filter, specify '*' as the filter", RED)); - sender.sendMessage(text("Usage: /paper entity list [filter] [worldKey]", RED)); - return; - } - Map>> list = Maps.newHashMap(); - @Nullable NamespacedKey worldKey = NamespacedKey.fromString(worldName); - @Nullable World bukkitWorld; - if (worldKey == null || (bukkitWorld = Bukkit.getWorld(worldKey)) == null) { - sender.sendMessage(text("Could not load world for " + worldName + ". Please select a valid world.", RED)); - sender.sendMessage(text("Usage: /paper entity list [filter] [worldKey]", RED)); + sender.sendMessage(text("Usage: /paper entity list [filter] [world]", RED)); return; } - ServerLevel world = ((CraftWorld) bukkitWorld).getHandle(); - Map nonEntityTicking = Maps.newHashMap(); - ServerChunkCache chunkProviderServer = world.getChunkSource(); - FeatureHooks.getAllEntities(world).forEach(e -> { + + Map>> list = new HashMap<>(); + ServerLevel level = ((CraftWorld) world).getHandle(); + Map nonEntityTicking = new HashMap<>(); + ServerChunkCache chunkProviderServer = level.getChunkSource(); + FeatureHooks.getAllEntities(level).forEach(e -> { Identifier key = EntityType.getKey(e.getType()); MutablePair> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap())); ChunkPos chunk = e.chunkPosition(); info.left++; info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1); - if (!world.isPositionEntityTicking(e.blockPosition()) || (e instanceof net.minecraft.world.entity.Marker && !world.paperConfig().entities.markers.tick)) { // Paper - Configurable marker ticking + if (!level.isPositionEntityTicking(e.blockPosition()) || (e instanceof net.minecraft.world.entity.Marker && !level.paperConfig().entities.markers.tick)) { // Paper - Configurable marker ticking nonEntityTicking.merge(key, 1, Integer::sum); } }); @@ -131,7 +133,7 @@ private void listEntities(final CommandSender sender, final String[] args) { final int z = (e.getKey().z() << 4) + 8; final Component message = text(" " + e.getValue() + ": " + e.getKey().x() + ", " + e.getKey().z() + (chunkProviderServer.isPositionTicking(e.getKey().pack()) ? " (Ticking)" : " (Non-Ticking)")) .hoverEvent(HoverEvent.showText(text("Click to teleport to chunk", GREEN))) - .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/minecraft:execute as @s in " + world.getWorld().getKey() + " run tp " + x + " " + (world.getWorld().getHighestBlockYAt(x, z, HeightMap.MOTION_BLOCKING) + 1) + " " + z)); + .clickEvent(ClickEvent.runCommand("/minecraft:execute as @s in " + MCUtil.getLevelName(level) + " run tp " + x + " " + (level.getWorld().getHighestBlockYAt(x, z, HeightMap.MOTION_BLOCKING) + 1) + " " + z)); sender.sendMessage(message); }); } else { diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java index 109803e887e9..0be14f948308 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Map; import java.util.function.ToIntFunction; -import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.JoinConfiguration; @@ -56,17 +55,15 @@ public boolean execute(final CommandSender sender, final String subCommand, fina @Override public List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { return switch (subCommand) { - case "mobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestMobcaps(args)); + case "mobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestMobcaps(sender, args)); case "playermobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestPlayerMobcaps(sender, args)); default -> throw new IllegalArgumentException(); }; } - private List suggestMobcaps(final String[] args) { + private List suggestMobcaps(final CommandSender sender, String[] args) { if (args.length == 1) { - final List worlds = new ArrayList<>(Bukkit.getWorlds().stream().map(World::getKey).map(NamespacedKey::toString).toList()); - worlds.add("*"); - return worlds; + return CommandUtil.getWorldSuggestions(sender.getServer(), true); } return Collections.emptyList(); @@ -92,17 +89,17 @@ private void printMobcaps(final CommandSender sender, final String[] args) { if (sender instanceof Player player) { worlds = List.of(player.getWorld()); } else { - sender.sendMessage(Component.text("Must specify a world! ex: '/paper mobcaps overworld'", NamedTextColor.RED)); + sender.sendMessage(Component.text("Must specify a world! ex: '/paper mobcaps minecraft:overworld'", NamedTextColor.RED)); return; } } else if (args.length == 1) { final String input = args[0]; if (input.equals("*")) { - worlds = Bukkit.getWorlds(); + worlds = Bukkit.getServer().getWorlds(); } else { - final @Nullable Key worldKey = NamespacedKey.fromString(input); - final @Nullable World world; - if (worldKey == null || (world = Bukkit.getWorld(worldKey)) == null) { + final @Nullable NamespacedKey worldKey = NamespacedKey.fromString(input); + final @Nullable World world = worldKey == null ? null : sender.getServer().getWorld(worldKey); + if (world == null) { sender.sendMessage(Component.text("'" + input + "' is not a valid world!", NamedTextColor.RED)); return; } else { @@ -126,7 +123,7 @@ private void printMobcaps(final CommandSender sender, final String[] args) { } sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for world: "), - Component.text(world.getKey().toString(), NamedTextColor.AQUA), + Component.text(world.key().asString(), NamedTextColor.AQUA), Component.text(" (" + chunks + " spawnable chunks)") )); diff --git a/paper-server/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java b/paper-server/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java index 95d6022c9cfb..8d87326f9040 100644 --- a/paper-server/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java +++ b/paper-server/src/main/java/io/papermc/paper/command/subcommands/SyncLoadInfoCommand.java @@ -13,8 +13,9 @@ import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Collections; import java.util.List; - +import java.util.Locale; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.minecraft.server.MinecraftServer; @@ -38,7 +39,10 @@ public boolean execute(final CommandSender sender, final String subCommand, fina @Override public List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { - return CommandUtil.getListMatchingLast(sender, args, "clear"); + if (args.length == 1) { + return CommandUtil.getListMatchingLast(sender, args, "clear"); + } + return Collections.emptyList(); } private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss"); @@ -53,7 +57,7 @@ private void doSyncLoadInfo(final CommandSender sender, final String[] args) { return; } - if (args.length > 0 && args[0].equals("clear")) { + if (args.length > 0 && args[0].toLowerCase(Locale.ROOT).equals("clear")) { SyncLoadFinder.clear(); sender.sendMessage(text("Sync load data cleared.", GRAY)); return; diff --git a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java index 1ab7f28e2ba3..aa5ff7fb46b0 100644 --- a/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/paper-server/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -11,9 +11,9 @@ import io.papermc.paper.configuration.mapping.MergeMap; import io.papermc.paper.configuration.serializer.ComponentSerializer; import io.papermc.paper.configuration.serializer.EnumValueSerializer; +import io.papermc.paper.configuration.serializer.IdentifierSerializer; import io.papermc.paper.configuration.serializer.NbtPathSerializer; import io.papermc.paper.configuration.serializer.ServerboundPacketClassSerializer; -import io.papermc.paper.configuration.serializer.IdentifierSerializer; import io.papermc.paper.configuration.serializer.StringRepresentableSerializer; import io.papermc.paper.configuration.serializer.collection.TableSerializer; import io.papermc.paper.configuration.serializer.collection.map.FastutilMapSerializer; @@ -54,7 +54,6 @@ import java.util.Locale; import java.util.function.Function; import java.util.function.Supplier; - import net.kyori.adventure.key.Key; import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentType; @@ -64,8 +63,8 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; -import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.apache.commons.lang3.RandomStringUtils; import org.bukkit.configuration.ConfigurationSection; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index 00bfa189936d..196816843eb7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -3,7 +3,6 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicates; import java.util.function.Predicate; - import net.kyori.adventure.key.Key; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 144079a7a002..578ad15a29b9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -37,8 +37,8 @@ public String get() { } value.append("}\n ").append(Bukkit.getScheduler().toString()); value.append("\n Force Loaded Chunks: {"); - for (World world : Bukkit.getWorlds()) { - value.append(' ').append(world.getKey().toString()).append(": {"); + for (World world : Bukkit.getServer().getWorlds()) { + value.append(' ').append(world.key().asString()).append(": {"); for (Map.Entry> entry : world.getPluginChunkTickets().entrySet()) { value.append(' ').append(entry.getKey().getDescription().getFullName()).append(": ").append(Integer.toString(entry.getValue().size())).append(','); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index a1194c617fe1..ab2224ecebc5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1403,7 +1403,7 @@ public World getWorld(net.kyori.adventure.key.Key worldKey) { public void addWorld(World world) { // Check if a World already exists with the UID. if (this.getWorld(world.getUID()) != null) { - System.out.println("World " + world.getKey() + " is a duplicate of another world and has been prevented from loading. Please remove or change the duplicated Paper world metadata before loading it again."); + System.out.println("World " + world.key().asString() + " is a duplicate of another world and has been prevented from loading. Please remove or change the duplicated Paper world metadata before loading it again."); return; } this.worlds.put(world.getName().toLowerCase(Locale.ROOT), world); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 885d5fe3ecd4..f77cb6d85c89 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -60,7 +60,6 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.util.NullOps; -import net.minecraft.util.TriState; import net.minecraft.world.attribute.BedRule; import net.minecraft.world.attribute.EnvironmentAttributes; import net.minecraft.world.entity.EntitySpawnReason; @@ -126,7 +125,6 @@ import org.bukkit.craftbukkit.util.CraftBiomeSearchResult; import org.bukkit.craftbukkit.util.CraftDifficulty; import org.bukkit.craftbukkit.util.CraftLocation; -import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftRayTraceResult; import org.bukkit.craftbukkit.util.CraftSpawnCategory; import org.bukkit.craftbukkit.util.CraftStructureSearchResult; @@ -175,6 +173,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); private static final PointersSupplier POINTERS_SUPPLIER = PointersSupplier.builder() .resolving(net.kyori.adventure.identity.Identity.NAME, World::getName) + // todo key pointer .resolving(net.kyori.adventure.identity.Identity.UUID, World::getUID) .build(); @@ -304,9 +303,9 @@ public boolean hasStructureAt(final io.papermc.paper.math.Position position, fin private static final Random rand = new Random(); - public CraftWorld(ServerLevel world, Identifier identifier, @Nullable BiomeProvider biomeProvider, Environment environment) { + public CraftWorld(ServerLevel world, NamespacedKey key, @Nullable BiomeProvider biomeProvider, Environment environment) { this.world = world; - this.key = CraftNamespacedKey.fromMinecraft(identifier); + this.key = key; this.biomeProvider = biomeProvider; this.environment = environment; @@ -786,7 +785,7 @@ public NamespacedKey getKey() { @Override public String toString() { - return "CraftWorld{key=" + this.getKey().toString() + '}'; + return "CraftWorld{key=" + this.key().asString() + '}'; } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index f93a66bab6de..f117b5fdb0d1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.block; -import java.util.Set; import com.mojang.logging.LogUtils; +import java.util.Set; import net.minecraft.core.RegistryAccess; import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponentPatch; @@ -54,13 +54,10 @@ public CraftBlockEntityState(World world, T blockEntity) { // Paper end // Paper start - Show blockstate location if we failed to read it } catch (Throwable thr) { - if (thr instanceof ThreadDeath) { - throw (ThreadDeath)thr; - } throw new RuntimeException( world == null ? "Failed to read non-placed BlockState" - : "Failed to read BlockState at: world: " + world.getKey() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", + : "Failed to read BlockState at: world: " + world.key().asString() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", thr ); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java index 4e9abf867891..523775bb96a8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/metadata/BlockMetadataStore.java @@ -46,7 +46,7 @@ protected String disambiguate(Block block, String metadataKey) { */ @Override public List getMetadata(Block block, String metadataKey) { - Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.getKey().toString()); + Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.key().asString()); return super.getMetadata(block, metadataKey); } @@ -58,7 +58,7 @@ public List getMetadata(Block block, String metadataKey) { */ @Override public boolean hasMetadata(Block block, String metadataKey) { - Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.getKey().toString()); + Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.key().asString()); return super.hasMetadata(block, metadataKey); } @@ -70,7 +70,7 @@ public boolean hasMetadata(Block block, String metadataKey) { */ @Override public void removeMetadata(Block block, String metadataKey, Plugin owningPlugin) { - Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.getKey().toString()); + Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.key().asString()); super.removeMetadata(block, metadataKey, owningPlugin); } @@ -82,7 +82,7 @@ public void removeMetadata(Block block, String metadataKey, Plugin owningPlugin) */ @Override public void setMetadata(Block block, String metadataKey, MetadataValue newMetadataValue) { - Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.getKey().toString()); + Preconditions.checkArgument(block.getWorld() == this.owningWorld, "Block does not belong to world %s", this.owningWorld.key().asString()); super.setMetadata(block, metadataKey, newMetadataValue); } }