Add getWorld method that uses adventure Key (#11199)

This commit is contained in:
kokiriglade
2024-08-19 10:41:55 +01:00
parent 5703e6c6d8
commit 9921a197e7
4 changed files with 31 additions and 8 deletions

View File

@@ -23,6 +23,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public static World getWorld(@NotNull NamespacedKey worldKey) {
+ return server.getWorld(worldKey);
+ }
+
+ /**
+ * Gets the world from the given Key
+ *
+ * @param worldKey the Key of the world to retrieve
+ * @return a world with the given Key, or null if none exists
+ */
+ @Nullable
+ public static World getWorld(@NotNull net.kyori.adventure.key.Key worldKey) {
+ return server.getWorld(worldKey);
+ }
+ // Paper end
/**
@@ -71,7 +82,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @return a world with the given NamespacedKey, or null if none exists
+ */
+ @Nullable
+ public World getWorld(@NotNull NamespacedKey worldKey);
+ default World getWorld(@NotNull NamespacedKey worldKey) {
+ return getWorld((net.kyori.adventure.key.Key) worldKey);
+ }
+
+ /**
+ * Gets the world from the given Key
+ *
+ * @param worldKey the Key of the world to retrieve
+ * @return a world with the given Key, or null if none exists
+ */
+ @Nullable
+ World getWorld(@NotNull net.kyori.adventure.key.Key worldKey);
+ // Paper end
+
/**