@@ -16,6 +16,8 @@ public abstract class Dupe {
1616 final protected GoldenDupes plugin ;
1717
1818 final static private boolean TOTEMS_EXIST ;
19+ final static private boolean USE_LEGACY_TOTEM ;
20+ final static private Material TOTEM_MATERIAL ;
1921 final static private boolean SHULKERS_EXIST ;
2022
2123 final static private EnumSet <Material > shulkerBoxes ;
@@ -30,17 +32,56 @@ public abstract class Dupe {
3032 private static int totemStackSize ;
3133
3234 static {
33- TOTEMS_EXIST = Material .matchMaterial ("minecraft:totem_of_undying" ) != null ;
34- SHULKERS_EXIST = Material .matchMaterial ("minecraft:shulker_shell" ) != null ;
3535
36- shulkerBoxes = EnumSet .noneOf (Material .class );
36+ boolean shulkersExist ;
37+ try {
38+ Material .valueOf ("SHULKER_SHELL" );
39+ shulkersExist = true ;
40+ }
41+ catch (IllegalArgumentException e ) {
42+ shulkersExist = false ;
43+ }
44+
45+ boolean totemsExist ;
46+ Material totemMaterial = null ;
47+ try {
48+ totemMaterial = Material .valueOf ("TOTEM_OF_UNDYING" );
49+ totemsExist = true ;
50+ }
51+ catch (IllegalArgumentException e ) {
52+ totemsExist = false ;
53+ }
54+
55+ boolean legacyTotems = false ;
56+
57+ if (!totemsExist ) {
58+ try {
59+ totemMaterial = Material .valueOf ("TOTEM" );
60+ legacyTotems = true ;
61+ totemsExist = true ;
62+ }
63+ catch (IllegalArgumentException e ) {
64+ legacyTotems = false ;
65+ }
66+ }
3767
68+ TOTEMS_EXIST = totemsExist ;
69+ TOTEM_MATERIAL = totemMaterial ;
3870
71+ SHULKERS_EXIST = shulkersExist ;
72+ USE_LEGACY_TOTEM = legacyTotems ;
73+
74+ shulkerBoxes = EnumSet .noneOf (Material .class );
75+
76+ System .out .println ("do shulkers exist? " +SHULKERS_EXIST );
77+ System .out .println ("do totems exist? " +TOTEMS_EXIST );
78+ System .out .println ("legacy totems? " +USE_LEGACY_TOTEM );
3979 // building an EnumSet of all colors of shulker box
40- if (SHULKERS_EXIST )
80+ if (SHULKERS_EXIST ) {
4181 Arrays .stream (Material .values ())
42- .filter (m -> m .name ().endsWith ("SHULKER_BOX" ))
82+ .filter (m -> m .name ().contains ("SHULKER_BOX" ))
4383 .forEach (shulkerBoxes ::add );
84+ }
4485 }
4586
4687
@@ -49,6 +90,7 @@ public Dupe(GoldenDupes plugin) {
4990
5091 }
5192
93+ // loads cofig values regarding item limits
5294 public static void loadConfig (FileConfiguration config ) {
5395 dupeNonStacking = config .getBoolean (NON_STACK_DO_DUPE .path ());
5496 nonStackingStackSize = config .getInt (NON_STACK_STACKSIZE .path ());
@@ -61,29 +103,32 @@ public static void loadConfig(FileConfiguration config) {
61103 }
62104
63105
106+
107+ // dupes an item
108+ // takes in the item to dupe and the maximum acceptable stack size before considering config limits
64109 public ItemStack dupe (ItemStack toDupe , int amount ) {
65110
111+
66112 if (toDupe == null )
67113 return new ItemStack (Material .AIR );
68114
69- boolean dupe = false ;
115+ boolean dupe = true ;
70116 int stacksize = amount ;
71117 boolean isSize64 = toDupe .getMaxStackSize () == 64 ;
72118
73-
74119 if (!isSize64 ) {
75120 dupe = dupeNonStacking ;
76- stacksize = Math .max (stacksize , nonStackingStackSize );
121+ stacksize = Math .max (amount , nonStackingStackSize );
77122 }
78123
79- if (TOTEMS_EXIST && toDupe .getType () == Material . TOTEM_OF_UNDYING ) {
124+ if (TOTEMS_EXIST && toDupe .getType () == TOTEM_MATERIAL ) {
80125 dupe = dupeTotems ;
81- stacksize = Math .max ( stacksize , totemStackSize );
126+ stacksize = Math .min ( amount , totemStackSize );
82127 }
83128
84129 if (SHULKERS_EXIST && shulkerBoxes .contains (toDupe .getType ())) {
85130 dupe = dupeShulkers ;
86- stacksize = Math .max ( stacksize , shulkerStackSize );
131+ stacksize = Math .min ( amount , shulkerStackSize );
87132 }
88133
89134 if (!dupe )
0 commit comments