11package me .hsgamer .bettergui .api .menu ;
22
3+ import me .hsgamer .bettergui .BetterGUI ;
34import me .hsgamer .bettergui .api .element .MenuElement ;
5+ import me .hsgamer .bettergui .manager .MenuManager ;
46import me .hsgamer .hscore .common .StringReplacer ;
57import me .hsgamer .hscore .config .Config ;
68import org .bukkit .entity .Player ;
@@ -19,7 +21,6 @@ public abstract class Menu implements MenuElement {
1921 public static final String MENU_SETTINGS_PATH = "menu-settings" ;
2022
2123 protected final Config config ;
22- private final Map <UUID , Menu > parentMenu = new HashMap <>();
2324
2425 /**
2526 * Create a new menu
@@ -63,7 +64,7 @@ public StringReplacer getStringReplacer() {
6364 @ Override
6465 public @ Nullable String replace (@ NotNull String original , @ NotNull UUID uuid ) {
6566 if (original .equalsIgnoreCase ("parent-menu" )) {
66- return getParentMenu (uuid ).map (Menu ::getName ).orElse (null );
67+ return BetterGUI . getInstance (). get ( MenuManager . class ). getParentMenu (uuid , Menu . this ).map (Menu ::getName ).orElse (null );
6768 }
6869 return replace (original );
6970 }
@@ -116,29 +117,4 @@ public List<String> tabComplete(Player player, String[] args) {
116117 * Close/Clear all inventories of the type
117118 */
118119 public abstract void closeAll ();
119-
120- /**
121- * Get the former menu that opened this menu
122- *
123- * @param uuid the unique id
124- *
125- * @return the former menu
126- */
127- public Optional <Menu > getParentMenu (UUID uuid ) {
128- return Optional .ofNullable (parentMenu .get (uuid ));
129- }
130-
131- /**
132- * Set the former menu
133- *
134- * @param uuid the unique id
135- * @param menu the former menu
136- */
137- public void setParentMenu (UUID uuid , Menu menu ) {
138- if (menu == null ) {
139- parentMenu .remove (uuid );
140- } else {
141- parentMenu .put (uuid , menu );
142- }
143- }
144120}
0 commit comments