9
9
10
10
import java .util .ArrayList ;
11
11
import java .util .Collection ;
12
- import java .util .HashMap ;
13
12
import java .util .List ;
14
13
import java .util .Locale ;
15
14
import java .util .Map ;
19
18
20
19
import org .bukkit .ChatColor ;
21
20
import org .bukkit .Material ;
21
+ import org .bukkit .Registry ;
22
22
import org .bukkit .World ;
23
23
import org .bukkit .block .Biome ;
24
24
import org .bukkit .entity .EntityType ;
@@ -295,18 +295,8 @@ public static <T> T getPreviousValue(T[] values, T currentValue)
295
295
*
296
296
* @return Map that contains relation from biome name to biome.
297
297
*/
298
- public static Map <String , Biome > getBiomeNameMap ()
299
- {
300
- Biome [] biomes = Biome .values ();
301
-
302
- Map <String , Biome > returnMap = new HashMap <>(biomes .length );
303
-
304
- for (Biome biome : biomes )
305
- {
306
- returnMap .put (biome .name (), biome );
307
- }
308
-
309
- return returnMap ;
298
+ public static Map <String , Biome > getBiomeNameMap () {
299
+ return Registry .BIOME .stream ().collect (Collectors .toMap (biome -> biome .name (), biome -> biome ));
310
300
}
311
301
312
302
@@ -398,11 +388,8 @@ public static String sanitizeInput(String input)
398
388
*/
399
389
public static boolean isSnowyBiome (Biome biome )
400
390
{
401
- return switch (biome ) {
402
- //case SNOWY_SLOPES:
403
- case SNOWY_PLAINS , SNOWY_TAIGA , ICE_SPIKES , FROZEN_RIVER , SNOWY_BEACH -> true ;
404
- default -> false ;
405
- };
391
+ return biome == Biome .SNOWY_PLAINS || biome == Biome .SNOWY_TAIGA || biome == Biome .ICE_SPIKES
392
+ || biome == Biome .FROZEN_RIVER || biome == Biome .SNOWY_BEACH ;
406
393
}
407
394
408
395
@@ -414,10 +401,9 @@ public static boolean isSnowyBiome(Biome biome)
414
401
*/
415
402
public static boolean isColdBiome (Biome biome )
416
403
{
417
- return switch (biome ) {
418
- case WINDSWEPT_HILLS , WINDSWEPT_GRAVELLY_HILLS , WINDSWEPT_FOREST , TAIGA , OLD_GROWTH_PINE_TAIGA , OLD_GROWTH_SPRUCE_TAIGA , STONY_SHORE -> true ;
419
- default -> false ;
420
- };
404
+ return biome == Biome .WINDSWEPT_HILLS || biome == Biome .WINDSWEPT_GRAVELLY_HILLS
405
+ || biome == Biome .WINDSWEPT_FOREST || biome == Biome .TAIGA || biome == Biome .OLD_GROWTH_PINE_TAIGA
406
+ || biome == Biome .OLD_GROWTH_SPRUCE_TAIGA || biome == Biome .STONY_SHORE ;
421
407
}
422
408
423
409
@@ -429,10 +415,11 @@ public static boolean isColdBiome(Biome biome)
429
415
*/
430
416
public static boolean isTemperateBiome (Biome biome )
431
417
{
432
- return switch (biome ) {
433
- case PLAINS , SUNFLOWER_PLAINS , FOREST , FLOWER_FOREST , BIRCH_FOREST , OLD_GROWTH_BIRCH_FOREST , DARK_FOREST , SWAMP , JUNGLE , SPARSE_JUNGLE , BAMBOO_JUNGLE , RIVER , BEACH , MUSHROOM_FIELDS -> true ;
434
- default -> false ;
435
- };
418
+ return biome == Biome .PLAINS || biome == Biome .SUNFLOWER_PLAINS || biome == Biome .FOREST
419
+ || biome == Biome .FLOWER_FOREST || biome == Biome .BIRCH_FOREST || biome == Biome .OLD_GROWTH_BIRCH_FOREST
420
+ || biome == Biome .DARK_FOREST || biome == Biome .SWAMP || biome == Biome .JUNGLE
421
+ || biome == Biome .SPARSE_JUNGLE || biome == Biome .BAMBOO_JUNGLE || biome == Biome .RIVER
422
+ || biome == Biome .BEACH || biome == Biome .MUSHROOM_FIELDS ;
436
423
}
437
424
438
425
@@ -444,12 +431,9 @@ public static boolean isTemperateBiome(Biome biome)
444
431
*/
445
432
public static boolean isWarmBiome (Biome biome )
446
433
{
447
- return switch (biome ) {
448
- case DESERT , SAVANNA , WINDSWEPT_SAVANNA , BADLANDS , ERODED_BADLANDS , WOODED_BADLANDS , SAVANNA_PLATEAU ->
449
- // case BADLANDS_PLATEAU:
450
- true ;
451
- default -> false ;
452
- };
434
+ return biome == Biome .DESERT || biome == Biome .SAVANNA || biome == Biome .WINDSWEPT_SAVANNA
435
+ || biome == Biome .BADLANDS || biome == Biome .ERODED_BADLANDS || biome == Biome .WOODED_BADLANDS
436
+ || biome == Biome .SAVANNA_PLATEAU ;
453
437
}
454
438
455
439
@@ -461,10 +445,9 @@ public static boolean isWarmBiome(Biome biome)
461
445
*/
462
446
public static boolean isAquaticBiome (Biome biome )
463
447
{
464
- return switch (biome ) {
465
- case WARM_OCEAN , LUKEWARM_OCEAN , DEEP_LUKEWARM_OCEAN , OCEAN , DEEP_OCEAN , COLD_OCEAN , DEEP_COLD_OCEAN , FROZEN_OCEAN , DEEP_FROZEN_OCEAN -> true ;
466
- default -> false ;
467
- };
448
+ return biome == Biome .WARM_OCEAN || biome == Biome .LUKEWARM_OCEAN || biome == Biome .DEEP_LUKEWARM_OCEAN
449
+ || biome == Biome .OCEAN || biome == Biome .DEEP_OCEAN || biome == Biome .COLD_OCEAN
450
+ || biome == Biome .DEEP_COLD_OCEAN || biome == Biome .FROZEN_OCEAN || biome == Biome .DEEP_FROZEN_OCEAN ;
468
451
}
469
452
470
453
@@ -486,12 +469,8 @@ public static boolean isNeutralBiome(Biome biome)
486
469
* @param biome Biome that must be checked.
487
470
* @return {@code true} if I think it is cave biome, {@code false} otherwise.
488
471
*/
489
- public static boolean isCaveBiome (Biome biome )
490
- {
491
- return switch (biome ) {
492
- case LUSH_CAVES , DRIPSTONE_CAVES -> true ;
493
- default -> false ;
494
- };
472
+ public static boolean isCaveBiome (Biome biome ) {
473
+ return biome == Biome .LUSH_CAVES || biome == Biome .DRIPSTONE_CAVES ;
495
474
}
496
475
497
476
@@ -501,12 +480,9 @@ public static boolean isCaveBiome(Biome biome)
501
480
* @param biome Biome that must be checked.
502
481
* @return {@code true} if I think it is nether biome, {@code false} otherwise.
503
482
*/
504
- public static boolean isNetherBiome (Biome biome )
505
- {
506
- return switch (biome ) {
507
- case NETHER_WASTES , SOUL_SAND_VALLEY , CRIMSON_FOREST , WARPED_FOREST , BASALT_DELTAS -> true ;
508
- default -> false ;
509
- };
483
+ public static boolean isNetherBiome (Biome biome ) {
484
+ return biome == Biome .NETHER_WASTES || biome == Biome .SOUL_SAND_VALLEY || biome == Biome .CRIMSON_FOREST
485
+ || biome == Biome .WARPED_FOREST || biome == Biome .BASALT_DELTAS ;
510
486
}
511
487
512
488
@@ -516,12 +492,9 @@ public static boolean isNetherBiome(Biome biome)
516
492
* @param biome Biome that must be checked.
517
493
* @return {@code true} if I think it is the end biome, {@code false} otherwise.
518
494
*/
519
- public static boolean isTheEndBiome (Biome biome )
520
- {
521
- return switch (biome ) {
522
- case THE_END , SMALL_END_ISLANDS , END_MIDLANDS , END_HIGHLANDS , END_BARRENS -> true ;
523
- default -> false ;
524
- };
495
+ public static boolean isTheEndBiome (Biome biome ) {
496
+ return biome == Biome .THE_END || biome == Biome .SMALL_END_ISLANDS || biome == Biome .END_MIDLANDS
497
+ || biome == Biome .END_HIGHLANDS || biome == Biome .END_BARRENS ;
525
498
}
526
499
527
500
@@ -633,7 +606,7 @@ public static String prettifyObject(Biome biome, User user)
633
606
// biomes:
634
607
// [biome]:
635
608
// name: [name]
636
- String translation = user .getTranslationOrNothing (Constants .BIOMES + biome .name ().toLowerCase () + ".name" );
609
+ String translation = user .getTranslationOrNothing (Constants .BIOMES + biome .getKey ().getKey () + ".name" );
637
610
638
611
if (!translation .isEmpty ())
639
612
{
@@ -646,7 +619,7 @@ public static String prettifyObject(Biome biome, User user)
646
619
// biomes:
647
620
// [biome]: [name]
648
621
649
- translation = user .getTranslationOrNothing (Constants .BIOMES + biome .name ().toLowerCase ());
622
+ translation = user .getTranslationOrNothing (Constants .BIOMES + biome .getKey ().getKey ());
650
623
651
624
if (!translation .isEmpty ())
652
625
{
@@ -658,7 +631,7 @@ public static String prettifyObject(Biome biome, User user)
658
631
// biomes:
659
632
// [biome]: [name]
660
633
661
- translation = user .getTranslationOrNothing ("biomes." + biome .name ().toLowerCase ());
634
+ translation = user .getTranslationOrNothing ("biomes." + biome .getKey ().getKey ());
662
635
663
636
if (!translation .isEmpty ())
664
637
{
@@ -667,7 +640,7 @@ public static String prettifyObject(Biome biome, User user)
667
640
}
668
641
669
642
// Nothing was found. Use just a prettify text function.
670
- return Util .prettifyText (biome .name ());
643
+ return Util .prettifyText (biome .getKey (). getKey ());
671
644
}
672
645
673
646
0 commit comments