22
33import me .hsgamer .bettergui .BetterGUI ;
44import me .hsgamer .bettergui .action .type .*;
5- import me .hsgamer .bettergui .api .action .MenuActionInput ;
65import me .hsgamer .bettergui .api .menu .Menu ;
6+ import me .hsgamer .bettergui .api .menu .MenuElement ;
77import me .hsgamer .hscore .action .builder .ActionInput ;
88import me .hsgamer .hscore .action .common .Action ;
99import me .hsgamer .hscore .bukkit .action .PlayerAction ;
1616/**
1717 * The action builder
1818 */
19- public final class ActionBuilder extends me .hsgamer .hscore .action .builder .ActionBuilder {
19+ public final class ActionBuilder extends me .hsgamer .hscore .action .builder .ActionBuilder < ActionBuilder . Input > {
2020 /**
2121 * The instance of the action builder
2222 */
2323 public static final ActionBuilder INSTANCE = new ActionBuilder ();
2424
2525 private ActionBuilder () {
2626 BukkitActionBuilder .register (this , BetterGUI .getInstance ());
27- register (input -> new OpenMenuAction (( MenuActionInput ) input ) , "open-menu" , "open" , "menu" , "open-menu" );
28- register (input -> new BackAction ((( MenuActionInput ) input ) .getMenu ()), "back-menu" , "backmenu" );
29- register (input -> new CloseMenuAction ((( MenuActionInput ) input ) .getMenu ()), "close-menu" , "closemenu" );
30- register (input -> new UpdateMenuAction ((( MenuActionInput ) input ) .getMenu ()), "update-menu" , "updatemenu" );
27+ register (OpenMenuAction :: new , "open-menu" , "open" , "menu" , "open-menu" );
28+ register (input -> new BackAction (input .getMenu ()), "back-menu" , "backmenu" );
29+ register (input -> new CloseMenuAction (input .getMenu ()), "close-menu" , "closemenu" );
30+ register (input -> new UpdateMenuAction (input .getMenu ()), "update-menu" , "updatemenu" );
3131 register (input -> new SoundAction (input .getValue ()), "sound" , "raw-sound" );
3232 }
3333
@@ -40,11 +40,41 @@ private ActionBuilder() {
4040 * @return the list of actions
4141 */
4242 public List <Action > build (Menu menu , Object object ) {
43- List <ActionInput > inputs = CollectionUtils .createStringListFromObject (object , true )
43+ List <Input > inputs = CollectionUtils .createStringListFromObject (object , true )
4444 .stream ()
4545 .map (ActionInput ::create )
46- .map (input -> MenuActionInput .create (menu , input ))
46+ .map (input -> Input .create (menu , input ))
4747 .collect (Collectors .toList ());
4848 return build (inputs , input -> new PlayerAction (BetterGUI .getInstance (), input .getValue ()));
4949 }
50+
51+ public interface Input extends ActionInput , MenuElement {
52+ static Input create (Menu menu , ActionInput input ) {
53+ return new Input () {
54+ @ Override
55+ public String getType () {
56+ return input .getType ();
57+ }
58+
59+ @ Override
60+ public String getOption () {
61+ return input .getOption ();
62+ }
63+
64+ @ Override
65+ public String getValue () {
66+ return input .getValue ();
67+ }
68+
69+ @ Override
70+ public Menu getMenu () {
71+ return menu ;
72+ }
73+ };
74+ }
75+
76+ static Input create (MenuElement menuElement , ActionInput input ) {
77+ return create (menuElement .getMenu (), input );
78+ }
79+ }
5080}
0 commit comments