55import me .hsgamer .bettergui .api .menu .StandardMenu ;
66import me .hsgamer .bettergui .builder .ButtonBuilder ;
77import me .hsgamer .bettergui .button .WrappedDummyButton ;
8+ import me .hsgamer .bettergui .manager .MenuCommandManager ;
89import me .hsgamer .bettergui .util .ProcessApplierConstants ;
10+ import me .hsgamer .bettergui .util .SchedulerUtil ;
911import me .hsgamer .bettergui .util .StringReplacerApplier ;
1012import me .hsgamer .hscore .bukkit .gui .object .BukkitItem ;
11- import me .hsgamer .hscore .bukkit .scheduler .Scheduler ;
1213import me .hsgamer .hscore .collections .map .CaseInsensitiveStringMap ;
1314import me .hsgamer .hscore .common .CollectionUtils ;
1415import me .hsgamer .hscore .common .StringReplacer ;
15- import me .hsgamer .hscore .config .CaseInsensitivePathString ;
1616import me .hsgamer .hscore .config .Config ;
17+ import me .hsgamer .hscore .minecraft .gui .button .DisplayButton ;
1718import me .hsgamer .hscore .minecraft .gui .object .Item ;
1819import me .hsgamer .hscore .task .BatchRunnable ;
1920import net .wesjd .anvilgui .AnvilGUI ;
2930public class AnvilMenu extends StandardMenu {
3031 private final Map <UUID , AnvilGUI > anvilGUIList = new ConcurrentHashMap <>();
3132 private final Map <UUID , String > userInputs = new ConcurrentHashMap <>();
32- private ActionApplier completeAction = new ActionApplier ( Collections . emptyList ()) ;
33- private ActionApplier closeAction = new ActionApplier ( Collections . emptyList ()) ;
33+ private ActionApplier completeAction = ActionApplier . EMPTY ;
34+ private ActionApplier closeAction = ActionApplier . EMPTY ;
3435 private String title ;
3536 private String text ;
3637 private WrappedButton button ;
@@ -56,25 +57,25 @@ protected AnvilMenu(Config config) {
5657 if (s .contains (" " )) {
5758 getInstance ().getLogger ().warning ("Illegal characters in command '" + s + "'" + "in the menu '" + getName () + "'. Ignored" );
5859 } else {
59- getInstance ().getMenuCommandManager ( ).registerMenuCommand (s , this );
60+ getInstance ().get ( MenuCommandManager . class ).registerMenuCommand (s , this );
6061 }
6162 }
6263 });
6364
64- for (Map .Entry <CaseInsensitivePathString , Object > entry : configSettings .entrySet ()) {
65- CaseInsensitivePathString key = entry .getKey ();
65+ for (Map .Entry <String , Object > entry : configSettings .entrySet ()) {
66+ String key = entry .getKey ();
6667 Object value = entry .getValue ();
6768 if (!(value instanceof Map )) {
6869 continue ;
6970 }
7071 //noinspection unchecked
7172 Map <String , Object > values = new CaseInsensitiveStringMap <>((Map <String , Object >) value );
72- if (key .equals ( new CaseInsensitivePathString ( "left-button" ) )) {
73+ if (key .equalsIgnoreCase ( "left-button" )) {
7374 leftButton = ButtonBuilder .INSTANCE .build (new ButtonBuilder .Input (this , "left_button" , values )).orElse (null );
7475 if (leftButton != null ) {
7576 leftButton .init ();
7677 }
77- } else if (key .equals ( new CaseInsensitivePathString ( "right-button" ) )) {
78+ } else if (key .equalsIgnoreCase ( "right-button" )) {
7879 rightButton = ButtonBuilder .INSTANCE .build (new ButtonBuilder .Input (this , "right_button" , values )).orElse (null );
7980 if (rightButton != null ) {
8081 rightButton .init ();
@@ -86,7 +87,11 @@ protected AnvilMenu(Config config) {
8687 }
8788 }
8889
89- private static Optional <ItemStack > getItem (Item item ) {
90+ private static Optional <ItemStack > getItem (DisplayButton displayButton ) {
91+ if (displayButton == null ) {
92+ return Optional .empty ();
93+ }
94+ Item item = displayButton .getItem ();
9095 if (item instanceof BukkitItem ) {
9196 return Optional .of (((BukkitItem ) item ).getItemStack ());
9297 }
@@ -101,9 +106,9 @@ public boolean create(Player player, String[] strings, boolean bypass) {
101106 batchRunnable
102107 .getTaskPool (ProcessApplierConstants .ACTION_STAGE )
103108 .addLast (process -> closeAction .accept (stateSnapshot .getPlayer ().getUniqueId (), process ));
104- Scheduler . current (). async ().runTask (batchRunnable );
109+ SchedulerUtil . async ().run (batchRunnable );
105110 });
106- builder .mainThreadExecutor (runnable -> Scheduler . current (). sync (). runEntityTask ( player , runnable ));
111+ builder .mainThreadExecutor (runnable -> SchedulerUtil . entity ( player ). run ( runnable ));
107112 builder .onClickAsync ((slot , stateSnapshot ) -> {
108113 if (slot != AnvilGUI .Slot .OUTPUT ) {
109114 return CompletableFuture .completedFuture (Collections .emptyList ());
@@ -122,7 +127,7 @@ public boolean create(Player player, String[] strings, boolean bypass) {
122127 }
123128
124129 return CompletableFuture
125- .runAsync (batchRunnable , runnable -> Scheduler . current (). async ().runTask (runnable ))
130+ .runAsync (batchRunnable , runnable -> SchedulerUtil . async ().run (runnable ))
126131 .thenApply (v -> Arrays .asList (
127132 AnvilGUI .ResponseAction .run (() -> remove (stateSnapshot .getPlayer ().getUniqueId (), false )),
128133 AnvilGUI .ResponseAction .close ()
@@ -142,15 +147,15 @@ public boolean create(Player player, String[] strings, boolean bypass) {
142147 }
143148
144149 if (button != null ) {
145- getItem (button .getItem (player .getUniqueId ())).ifPresent (builder ::itemOutput );
150+ getItem (button .display (player .getUniqueId ())).ifPresent (builder ::itemOutput );
146151 }
147152
148153 if (leftButton != null ) {
149- getItem (leftButton .getItem (player .getUniqueId ())).ifPresent (builder ::itemLeft );
154+ getItem (leftButton .display (player .getUniqueId ())).ifPresent (builder ::itemLeft );
150155 }
151156
152157 if (rightButton != null ) {
153- getItem (rightButton .getItem (player .getUniqueId ())).ifPresent (builder ::itemRight );
158+ getItem (rightButton .display (player .getUniqueId ())).ifPresent (builder ::itemRight );
154159 }
155160
156161 anvilGUIList .put (player .getUniqueId (), builder .open (player ));
0 commit comments