Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
d1a72eac31
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
85 Zeilen
4.2 KiB
Diff
85 Zeilen
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Wed, 6 Jan 2021 00:34:04 -0800
|
|
Subject: [PATCH] Expand world key API
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
index 1963e826548c5a8859c50f57654784c3aef50e44..04a39cb6c13c26e2cb1d73a9da98df5d04df69bc 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
@@ -515,5 +515,10 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
|
public io.papermc.paper.world.MoonPhase getMoonPhase() {
|
|
return io.papermc.paper.world.MoonPhase.getPhase(this.getHandle().dayTime() / 24000L);
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public org.bukkit.NamespacedKey getKey() {
|
|
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location());
|
|
+ }
|
|
// Paper end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index e4fab101b2d10759b9bd65d35715e377236a5989..99ff052c1935b9eba5fc519ae18c335893595337 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1181,9 +1181,15 @@ public final class CraftServer implements Server {
|
|
File folder = new File(this.getWorldContainer(), name);
|
|
World world = this.getWorld(name);
|
|
|
|
- if (world != null) {
|
|
- return world;
|
|
+ // Paper start
|
|
+ World worldByKey = this.getWorld(creator.key());
|
|
+ if (world != null || worldByKey != null) {
|
|
+ if (world == worldByKey) {
|
|
+ return world;
|
|
+ }
|
|
+ throw new IllegalArgumentException("Cannot create a world with key " + creator.key() + " and name " + name + " one (or both) already match a world that exists");
|
|
}
|
|
+ // Paper end
|
|
|
|
if (folder.exists()) {
|
|
Preconditions.checkArgument(folder.isDirectory(), "File (%s) exists and isn't a folder", name);
|
|
@@ -1309,7 +1315,7 @@ public final class CraftServer implements Server {
|
|
} else if (name.equals(levelName + "_the_end")) {
|
|
worldKey = net.minecraft.world.level.Level.END;
|
|
} else {
|
|
- worldKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace(name.toLowerCase(Locale.ROOT)));
|
|
+ worldKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.fromNamespaceAndPath(creator.key().namespace(), creator.key().value()));
|
|
}
|
|
|
|
// If set to not keep spawn in memory (changed from default) then adjust rule accordingly
|
|
@@ -1405,6 +1411,15 @@ public final class CraftServer implements Server {
|
|
return null;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public World getWorld(net.kyori.adventure.key.Key worldKey) {
|
|
+ ServerLevel worldServer = console.getLevel(ResourceKey.create(net.minecraft.core.registries.Registries.DIMENSION, io.papermc.paper.adventure.PaperAdventure.asVanilla(worldKey)));
|
|
+ if (worldServer == null) return null;
|
|
+ return worldServer.getWorld();
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public void addWorld(World world) {
|
|
// Check if a World already exists with the UID.
|
|
if (this.getWorld(world.getUID()) != null) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
index 481aeb922952578ea68ce2425c84e1a93eff0cf9..b075d4b21b53a3f39094444e4024556b23e399f2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -516,6 +516,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
public int nextEntityId() {
|
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public String getMainLevelName() {
|
|
+ return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
|
+ }
|
|
// Paper end
|
|
|
|
@Override
|