11package com .laytonsmith .abstraction .enums .bukkit ;
22
33import com .laytonsmith .abstraction .Implementation ;
4- import com .laytonsmith .abstraction .bukkit .BukkitMCServer ;
54import com .laytonsmith .abstraction .enums .EnumConvertor ;
65import com .laytonsmith .abstraction .enums .MCTreeType ;
7- import com .laytonsmith .abstraction .enums .MCVersion ;
86import com .laytonsmith .annotations .abstractionenum ;
9- import com .laytonsmith .core .Static ;
107import org .bukkit .TreeType ;
118
12- import java .util .Random ;
13-
149@ abstractionenum (
1510 implementation = Implementation .Type .BUKKIT ,
1611 forAbstractEnum = MCTreeType .class ,
@@ -29,27 +24,29 @@ public static com.laytonsmith.abstraction.enums.bukkit.BukkitMCTreeType getConve
2924
3025 @ Override
3126 protected MCTreeType getAbstractedEnumCustom (TreeType concrete ) {
32- if (!((BukkitMCServer ) Static .getServer ()).isPaper ()
33- && Static .getServer ().getMinecraftVersion ().gte (MCVersion .MC26_3 )) {
34- switch (concrete .name ()) {
35- case "RED_POPLAR" :
36- case "ORANGE_POPLAR" :
37- case "YELLOW_POPLAR" :
38- return MCTreeType .POPLAR ;
27+ try {
28+ return super .getAbstractedEnumCustom (concrete );
29+ } catch (IllegalArgumentException ex ) {
30+ // Poplar variants were briefly merged on Paper 26.3
31+ if (concrete .name ().equals ("POPLAR" )) {
32+ return MCTreeType .ORANGE_POPLAR ;
3933 }
34+ throw ex ;
4035 }
41- return super .getAbstractedEnumCustom (concrete );
4236 }
4337
4438 @ Override
4539 protected TreeType getConcreteEnumCustom (MCTreeType abstracted ) {
46- if (!((BukkitMCServer ) Static .getServer ()).isPaper ()
47- && Static .getServer ().getMinecraftVersion ().gte (MCVersion .MC26_3 )) {
48- if (abstracted == MCTreeType .POPLAR ) {
49- String [] colors = new String []{"RED" , "ORANGE" , "YELLOW" };
50- return TreeType .valueOf (colors [Math .abs (new Random ().nextInt ()) % 3 ] + "_POPLAR" );
40+ try {
41+ return super .getConcreteEnumCustom (abstracted );
42+ } catch (IllegalArgumentException ex ) {
43+ // Poplar variants were briefly merged on Paper 26.3
44+ if (abstracted == MCTreeType .ORANGE_POPLAR
45+ || abstracted == MCTreeType .RED_POPLAR
46+ || abstracted == MCTreeType .YELLOW_POPLAR ) {
47+ return TreeType .valueOf ("POPLAR" );
5148 }
49+ throw ex ;
5250 }
53- return super .getConcreteEnumCustom (abstracted );
5451 }
5552}
0 commit comments