mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Fix cb's janky level name in WorldCreator (#7851)
This commit is contained in:
@@ -49,6 +49,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
/**
|
||||
* Create a new virtual {@link WorldBorder}.
|
||||
* <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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/WorldCreator.java
|
||||
@@ -67,9 +82,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public WorldCreator(@NotNull String name) {
|
||||
- if (name == null) {
|
||||
- throw new IllegalArgumentException("World name cannot be null");
|
||||
- }
|
||||
+ // 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;
|
||||
|
@@ -65,9 +65,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- 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
|
||||
* 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.
|
||||
|
Reference in New Issue
Block a user