From 292dae65cb01929dc2158f09bdb19fdc82b3669f Mon Sep 17 00:00:00 2001 From: Maddy Miller Date: Fri, 12 Jul 2024 12:02:09 +1000 Subject: [PATCH] Use Bukkit Registry API where possible (#2573) --- .../worldedit/bukkit/WorldEditPlugin.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index a84370da7c..e1ae9079c3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -63,8 +63,8 @@ import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.Registry; import org.bukkit.Tag; -import org.bukkit.block.Biome; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -208,14 +208,14 @@ private void setupWorldData() { @SuppressWarnings({ "unchecked" }) private void initializeRegistries() { // Biome - for (Biome biome : Biome.values()) { + Registry.BIOME.forEach(biome -> { if (!biome.name().equals("CUSTOM")) { String key = biome.getKey().toString(); BiomeType.REGISTRY.register(key, new BiomeType(key)); } - } + }); // Block & Item - for (Material material : Material.values()) { + Registry.MATERIAL.forEach(material -> { if (material.isBlock()) { BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> { // TODO Use something way less hacky than this. @@ -242,16 +242,13 @@ private void initializeRegistries() { if (material.isItem()) { ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString())); } - } + }); // Entity - for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) { - if (entityType == org.bukkit.entity.EntityType.UNKNOWN) { - // This doesn't have a key - skip it - continue; - } + Registry.ENTITY_TYPE.forEach(entityType -> { String key = entityType.getKey().toString(); EntityType.REGISTRY.register(key, new EntityType(key)); - } + }); + // ... :| GameModes.get(""); WeatherTypes.get("");