13
0
geforkt von Mirrors/Paper

Add STRUCTURE_TYPE registry entry (#6400)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-01-23 11:12:42 -08:00
Ursprung 0c5c3e2248
Commit 51cd82371b

Datei anzeigen

@ -0,0 +1,60 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 14 Aug 2021 16:19:03 -0700
Subject: [PATCH] Expand the Registry API
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/Registry.java
+++ b/src/main/java/org/bukkit/Registry.java
@@ -0,0 +0,0 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
return Arrays.stream(org.bukkit.potion.PotionEffectType.values()).iterator();
}
};
+
+ /**
+ * Structure types.
+ *
+ * @see StructureType
+ */
+ Registry<StructureType> STRUCTURE_TYPE = new Registry<StructureType>() {
+
+ @Override
+ public @Nullable StructureType get(@NotNull NamespacedKey key) {
+ return StructureType.getStructureTypes().get(key.getKey());
+ }
+
+ @NotNull
+ @Override
+ public Iterator<StructureType> iterator() {
+ return StructureType.getStructureTypes().values().iterator();
+ }
+ };
// Paper end
/**
diff --git a/src/main/java/org/bukkit/StructureType.java b/src/main/java/org/bukkit/StructureType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/StructureType.java
+++ b/src/main/java/org/bukkit/StructureType.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
* The registration of new {@link StructureType}s is case-sensitive.
*/
// Order is retrieved from WorldGenFactory
-public final class StructureType {
+public final class StructureType implements Keyed { // Paper - implement keyed
private static final Map<String, StructureType> structureTypeMap = new HashMap<>();
@@ -0,0 +0,0 @@ public final class StructureType {
public static Map<String, StructureType> getStructureTypes() {
return ImmutableMap.copyOf(structureTypeMap);
}
+ // Paper start
+ @Override
+ public @NotNull NamespacedKey getKey() {
+ return NamespacedKey.minecraft(this.name);
+ }
+ // Paper end
}