Commits

DerFrZocker authored and md_5 committed d8d04ae927d
#1080: Deprecate registries which are not true server-side registries
No tags

src/main/java/org/bukkit/Registry.java

Modified
23 23 import org.bukkit.entity.Frog;
24 24 import org.bukkit.entity.Villager;
25 25 import org.bukkit.entity.Wolf;
26 26 import org.bukkit.entity.memory.MemoryKey;
27 27 import org.bukkit.generator.structure.Structure;
28 28 import org.bukkit.generator.structure.StructureType;
29 29 import org.bukkit.inventory.ItemType;
30 30 import org.bukkit.inventory.MenuType;
31 31 import org.bukkit.inventory.meta.trim.TrimMaterial;
32 32 import org.bukkit.inventory.meta.trim.TrimPattern;
33 +import org.bukkit.loot.LootTable;
33 34 import org.bukkit.loot.LootTables;
34 35 import org.bukkit.map.MapCursor;
35 36 import org.bukkit.potion.PotionEffectType;
36 37 import org.bukkit.potion.PotionType;
37 38 import org.jetbrains.annotations.ApiStatus;
38 39 import org.jetbrains.annotations.NotNull;
39 40 import org.jetbrains.annotations.Nullable;
40 41
41 42 /**
42 43 * Represents a registry of Bukkit objects that may be retrieved by
43 44 * {@link NamespacedKey}.
44 45 *
45 46 * @param <T> type of item in the registry
46 47 */
47 48 public interface Registry<T extends Keyed> extends Iterable<T> {
48 49
49 50 /**
50 51 * Server advancements.
51 52 *
52 53 * @see Bukkit#getAdvancement(org.bukkit.NamespacedKey)
53 54 * @see Bukkit#advancementIterator()
55 + * @deprecated Advancement has no real server-side registry.
54 56 */
57 + @Deprecated(since = "1.21.4")
55 58 Registry<Advancement> ADVANCEMENT = new Registry<Advancement>() {
56 59
57 60 @Nullable
58 61 @Override
59 62 public Advancement get(@NotNull NamespacedKey key) {
60 63 return Bukkit.getAdvancement(key);
61 64 }
62 65
63 66 @NotNull
64 67 @Override
112 115 * @see BlockType
113 116 * @apiNote BlockType is not ready for public usage yet
114 117 */
115 118 @ApiStatus.Internal
116 119 Registry<BlockType> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug.");
117 120 /**
118 121 * Custom boss bars.
119 122 *
120 123 * @see Bukkit#getBossBar(org.bukkit.NamespacedKey)
121 124 * @see Bukkit#getBossBars()
125 + * @deprecated BossBar has no real server-side registry.
122 126 */
127 + @Deprecated(since = "1.21.4")
123 128 Registry<KeyedBossBar> BOSS_BARS = new Registry<KeyedBossBar>() {
124 129
125 130 @Nullable
126 131 @Override
127 132 public KeyedBossBar get(@NotNull NamespacedKey key) {
128 133 return Bukkit.getBossBar(key);
129 134 }
130 135
131 136 @NotNull
132 137 @Override
179 184 *
180 185 * @see ItemType
181 186 * @apiNote ItemType is not ready for public usage yet
182 187 */
183 188 @ApiStatus.Internal
184 189 Registry<ItemType> ITEM = Objects.requireNonNull(Bukkit.getRegistry(ItemType.class), "No registry present for ItemType. This is a bug.");
185 190 /**
186 191 * Default server loot tables.
187 192 *
188 193 * @see LootTables
194 + * @deprecated LootTables, not to be confused with the {@link LootTable} class, has no real server-side registry.
189 195 */
196 + @Deprecated(since = "1.21.4")
190 197 Registry<LootTables> LOOT_TABLES = new SimpleRegistry<>(LootTables.class);
191 198 /**
192 199 * Server materials.
193 200 *
194 201 * @see Material
195 202 */
196 203 Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy());
197 204 /**
198 205 * Server menus.
199 206 *

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut