mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix cb's janky level name in WorldCreator (#7851)
This commit is contained in:
parent
a093b95db2
commit
f0b4d5aa22
4 changed files with 49 additions and 6 deletions
|
@ -49,6 +49,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
/**
|
/**
|
||||||
* Create a new virtual {@link WorldBorder}.
|
* Create a new virtual {@link WorldBorder}.
|
||||||
* <p>
|
* <p>
|
||||||
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||||
|
* @throws IllegalArgumentException if there isn't a registry for that type
|
||||||
|
*/
|
||||||
|
<T extends Keyed> @org.jetbrains.annotations.NotNull Registry<T> registryFor(Class<T> classOfT);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Just don't use it.
|
||||||
|
+ */
|
||||||
|
+ @org.jetbrains.annotations.NotNull String getMainLevelName();
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/WorldCreator.java b/src/main/java/org/bukkit/WorldCreator.java
|
diff --git a/src/main/java/org/bukkit/WorldCreator.java b/src/main/java/org/bukkit/WorldCreator.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/WorldCreator.java
|
--- a/src/main/java/org/bukkit/WorldCreator.java
|
||||||
|
@ -67,9 +82,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public WorldCreator(@NotNull String name) {
|
public WorldCreator(@NotNull String name) {
|
||||||
- if (name == null) {
|
- if (name == null) {
|
||||||
- throw new IllegalArgumentException("World name cannot be null");
|
- throw new IllegalArgumentException("World name cannot be null");
|
||||||
- }
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ this(name, NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_")));
|
+ this(name, getWorldKey(name));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static NamespacedKey getWorldKey(String name) {
|
||||||
|
+ final String mainLevelName = Bukkit.getUnsafe().getMainLevelName();
|
||||||
|
+ if (name.equals(mainLevelName)) {
|
||||||
|
+ return NamespacedKey.minecraft("overworld");
|
||||||
|
+ } else if (name.equals(mainLevelName + "_nether")) {
|
||||||
|
+ return NamespacedKey.minecraft("the_nether");
|
||||||
|
+ } else if (name.equals(mainLevelName + "_the_end")) {
|
||||||
|
+ return NamespacedKey.minecraft("the_end");
|
||||||
|
+ } else {
|
||||||
|
+ return NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_"));
|
||||||
|
}
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
- this.name = name;
|
- this.name = name;
|
||||||
|
|
|
@ -65,9 +65,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||||
* @throws IllegalArgumentException if there isn't a registry for that type
|
* Just don't use it.
|
||||||
*/
|
*/
|
||||||
<T extends Keyed> @org.jetbrains.annotations.NotNull Registry<T> registryFor(Class<T> classOfT);
|
@org.jetbrains.annotations.NotNull String getMainLevelName();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the item rarity of a material. The material <b>MUST</b> be an item.
|
+ * Gets the item rarity of a material. The material <b>MUST</b> be an item.
|
||||||
|
|
|
@ -51,3 +51,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public void addWorld(World world) {
|
public void addWorld(World world) {
|
||||||
// Check if a World already exists with the UID.
|
// Check if a World already exists with the UID.
|
||||||
if (this.getWorld(world.getUID()) != null) {
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||||
|
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||||
|
public <T extends org.bukkit.Keyed> Registry<T> registryFor(Class<T> classOfT) {
|
||||||
|
return io.papermc.paper.registry.PaperRegistry.getRegistry(classOfT);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getMainLevelName() {
|
||||||
|
+ return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
|
@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||||
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||||
public <T extends org.bukkit.Keyed> Registry<T> registryFor(Class<T> classOfT) {
|
public String getMainLevelName() {
|
||||||
return io.papermc.paper.registry.PaperRegistry.getRegistry(classOfT);
|
return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
|
Loading…
Reference in a new issue