6262import org .bstats .charts .SimplePie ;
6363import org .bukkit .Bukkit ;
6464import org .bukkit .Material ;
65- import org .bukkit .NamespacedKey ;
65+ import org .bukkit .Registry ;
6666import org .bukkit .Tag ;
67- import org .bukkit .block .Biome ;
6867import org .bukkit .command .BlockCommandSender ;
6968import org .bukkit .command .Command ;
7069import org .bukkit .command .CommandSender ;
8988import java .nio .file .Path ;
9089import java .nio .file .Paths ;
9190import java .util .List ;
92- import java .util .Locale ;
9391import java .util .Optional ;
9492
9593import static com .google .common .base .Preconditions .checkNotNull ;
@@ -250,21 +248,23 @@ private void setupWorldData() {
250248 // datapacks aren't loaded until just before the world is, and bukkit has no event for this
251249 // so the earliest we can do this is in WorldInit
252250 setupTags ();
253- setupBiomes (false ); // FAWE - load biomes later. Initialize biomes twice to allow for the registry to be present for
254251 // plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
255252 WorldEdit .getInstance ().getEventBus ().post (new PlatformReadyEvent (platform ));
256253 }
257254
258255 @ SuppressWarnings ({"deprecation" , "unchecked" })
259256 private void initializeRegistries () {
260- // FAWE start - move Biomes to their own method. Initialize biomes twice to allow for the registry to be present for
261- // plugins requiring WE biomes during startup, as well as allowing custom biomes loaded later on to be present in WE.
262- setupBiomes (true );
263- // FAWE end
257+ // Biome
258+ Registry .BIOME .forEach (biome -> {
259+ if (!biome .name ().equals ("CUSTOM" )) {
260+ String key = biome .getKey ().toString ();
261+ BiomeType .REGISTRY .register (key , new BiomeType (key ));
262+ }
263+ });
264264 /*
265265
266266 // Block & Item
267- for (Material material : Material.values()) {
267+ Registry.MATERIAL.forEach( material -> {
268268 if (material.isBlock() && !material.isLegacy()) {
269269 BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
270270 // TODO Use something way less hacky than this.
@@ -291,17 +291,14 @@ private void initializeRegistries() {
291291 if (material.isItem() && !material.isLegacy()) {
292292 ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
293293 }
294- }
295- */
296-
294+ });
295+ */
297296 // Entity
298- for (org .bukkit .entity .EntityType entityType : org .bukkit .entity .EntityType .values ()) {
299- String mcid = entityType .getName ();
300- if (mcid != null ) {
301- String lowerCaseMcId = mcid .toLowerCase (Locale .ROOT );
302- EntityType .REGISTRY .register ("minecraft:" + lowerCaseMcId , new EntityType ("minecraft:" + lowerCaseMcId ));
303- }
304- }
297+ Registry .ENTITY_TYPE .forEach (entityType -> {
298+ String key = entityType .getKey ().toString ();
299+ EntityType .REGISTRY .register (key , new EntityType (key ));
300+ });
301+
305302 // ... :|
306303 GameModes .get ("" );
307304 WeatherTypes .get ("" );
@@ -322,38 +319,6 @@ private void setupTags() {
322319 }
323320 }
324321
325- // FAWE start
326- private void setupBiomes (boolean expectFail ) {
327- if (this .adapter .value ().isPresent ()) {
328- // Biomes are stored globally in the server. Registries are not kept per-world in Minecraft.
329- // The WorldServer get-registries method simply delegates to the MinecraftServer method.
330- for (final NamespacedKey biome : ((BukkitImplAdapter <?>) adapter .value ().get ()).getRegisteredBiomes ()) {
331- BiomeType biomeType ;
332- if ((biomeType = BiomeType .REGISTRY .get (biome .toString ())) == null ) { // only register once
333- biomeType = new BiomeType (biome .toString ());
334- BiomeType .REGISTRY .register (biome .toString (), biomeType );
335- }
336- biomeType .setLegacyId (adapter .value ().get ().getInternalBiomeId (biomeType ));
337- }
338- } else {
339- if (!expectFail ) {
340- LOGGER .warn ("Failed to load biomes via adapter (not present). Will load via bukkit" );
341- }
342- for (Biome biome : Biome .values ()) {
343- // Custom is bad
344- if (biome .name ().equals ("CUSTOM" )) {
345- continue ;
346- }
347- String lowerCaseBiome = biome .getKey ().toString ().toLowerCase (Locale .ROOT );
348- // only register once
349- if (BiomeType .REGISTRY .get (lowerCaseBiome ) == null ) {
350- BiomeType .REGISTRY .register (lowerCaseBiome , new BiomeType (lowerCaseBiome ));
351- }
352- }
353- }
354- }
355- // FAWE end
356-
357322 private void loadAdapter () {
358323 WorldEdit worldEdit = WorldEdit .getInstance ();
359324
0 commit comments