Skip to content

Commit 9490475

Browse files
Add STRUCTURE_TYPE registry entry (#6400)
1 parent 7978121 commit 9490475

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Jake Potrebic <jake.m.potrebic@gmail.com>
3+
Date: Sat, 14 Aug 2021 16:19:03 -0700
4+
Subject: [PATCH] Expand the Registry API
5+
6+
7+
diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java
8+
index 6242336de18fdd708cc3d7b745cbbace13140bc0..661d424c609a01ad9bee837b4069d9e4e98d20c0 100644
9+
--- a/src/main/java/org/bukkit/Registry.java
10+
+++ b/src/main/java/org/bukkit/Registry.java
11+
@@ -209,6 +209,25 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
12+
return Arrays.stream(org.bukkit.potion.PotionEffectType.values()).iterator();
13+
}
14+
};
15+
+
16+
+ /**
17+
+ * Structure types.
18+
+ *
19+
+ * @see StructureType
20+
+ */
21+
+ Registry<StructureType> STRUCTURE_TYPE = new Registry<StructureType>() {
22+
+
23+
+ @Override
24+
+ public @Nullable StructureType get(@NotNull NamespacedKey key) {
25+
+ return StructureType.getStructureTypes().get(key.getKey());
26+
+ }
27+
+
28+
+ @NotNull
29+
+ @Override
30+
+ public Iterator<StructureType> iterator() {
31+
+ return StructureType.getStructureTypes().values().iterator();
32+
+ }
33+
+ };
34+
// Paper end
35+
36+
/**
37+
diff --git a/src/main/java/org/bukkit/StructureType.java b/src/main/java/org/bukkit/StructureType.java
38+
index 8acb2b9de398ab5f4b18c46e9ab9eb964df8be3f..5558daa9512212a4b05f174b64c4c998ebbccfcc 100644
39+
--- a/src/main/java/org/bukkit/StructureType.java
40+
+++ b/src/main/java/org/bukkit/StructureType.java
41+
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable;
42+
* The registration of new {@link StructureType}s is case-sensitive.
43+
*/
44+
// Order is retrieved from WorldGenFactory
45+
-public final class StructureType {
46+
+public final class StructureType implements Keyed { // Paper - implement keyed
47+
48+
private static final Map<String, StructureType> structureTypeMap = new HashMap<>();
49+
50+
@@ -244,4 +244,10 @@ public final class StructureType {
51+
public static Map<String, StructureType> getStructureTypes() {
52+
return ImmutableMap.copyOf(structureTypeMap);
53+
}
54+
+ // Paper start
55+
+ @Override
56+
+ public @NotNull NamespacedKey getKey() {
57+
+ return NamespacedKey.minecraft(this.name);
58+
+ }
59+
+ // Paper end
60+
}

0 commit comments

Comments
 (0)