@@ -49,14 +49,25 @@ public class GUI {
4949 private final Plugin plugin ;
5050 private final boolean filterItemsOnImport ;
5151 private static final Set <UUID > kitDeletionFlag = new HashSet <>();
52- private static final Map <UUID , UUID > inspectTargets = new HashMap <>();
52+ private static final Map <UUID , EditorContext > editorContexts = new HashMap <>();
5353
54- public static void setInspectTarget (UUID inspector , UUID target ) {
55- inspectTargets .put (inspector , target );
54+ public enum EditorType {
55+ KIT ,
56+ PUBLIC_KIT ,
57+ ENDERCHEST ,
58+ INSPECT_KIT ,
59+ INSPECT_ENDERCHEST
5660 }
5761
58- public static UUID getAndRemoveInspectTarget (UUID inspector ) {
59- return inspectTargets .remove (inspector );
62+ public record EditorContext (EditorType type , int slot , String id , UUID target , String playerName ) {
63+ }
64+
65+ public static EditorContext getAndRemoveEditorContext (UUID viewer ) {
66+ return editorContexts .remove (viewer );
67+ }
68+
69+ private static void setEditorContext (Player viewer , EditorContext context ) {
70+ editorContexts .put (viewer .getUniqueId (), context );
6071 }
6172
6273 public GUI (Plugin plugin ) {
@@ -106,6 +117,7 @@ public void OpenKitMenu(Player p, int slot) {
106117 menu .setCursorDropHandler (Menu .ALLOW_CURSOR_DROPPING );
107118
108119 menu .open (p );
120+ setEditorContext (p , new EditorContext (EditorType .KIT , slot , null , null , null ));
109121 }
110122
111123 public void OpenPublicKitEditor (Player p , String kitId ) {
@@ -130,6 +142,7 @@ public void OpenPublicKitEditor(Player p, String kitId) {
130142 menu .setCursorDropHandler (Menu .ALLOW_CURSOR_DROPPING );
131143
132144 menu .open (p );
145+ setEditorContext (p , new EditorContext (EditorType .PUBLIC_KIT , 0 , kitId , null , null ));
133146 }
134147
135148 public void OpenECKitKenu (Player p , int slot ) {
@@ -153,11 +166,14 @@ public void OpenECKitKenu(Player p, int slot) {
153166 addImportEC (menu .getSlot (IMPORT_SLOT ));
154167 menu .setCursorDropHandler (Menu .ALLOW_CURSOR_DROPPING );
155168 menu .open (p );
169+ setEditorContext (p , new EditorContext (EditorType .ENDERCHEST , slot , null , null , null ));
156170 }
157171
158172 public void InspectKit (Player p , UUID target , int slot ) {
159- setInspectTarget (p .getUniqueId (), target );
160173 String playerName = getPlayerName (target );
174+ if (playerName == null ) {
175+ playerName = target .toString ();
176+ }
161177 Menu menu = GuiMenuFactory .createInspectMenu (slot , playerName );
162178
163179 if (KitManager .get ().hasKit (target , slot )) {
@@ -184,11 +200,11 @@ public void InspectKit(Player p, UUID target, int slot) {
184200
185201 menu .setCursorDropHandler (Menu .ALLOW_CURSOR_DROPPING );
186202 menu .open (p );
203+ setEditorContext (p , new EditorContext (EditorType .INSPECT_KIT , slot , null , target , playerName ));
187204 SoundManager .playOpenGui (p );
188205 }
189206
190207 public void InspectEc (Player p , UUID target , int slot ) {
191- setInspectTarget (p .getUniqueId (), target );
192208 String playerName = getPlayerName (target );
193209 if (playerName == null ) {
194210 playerName = target .toString ();
@@ -220,6 +236,7 @@ public void InspectEc(Player p, UUID target, int slot) {
220236
221237 menu .setCursorDropHandler (Menu .ALLOW_CURSOR_DROPPING );
222238 menu .open (p );
239+ setEditorContext (p , new EditorContext (EditorType .INSPECT_ENDERCHEST , slot , null , target , playerName ));
223240 SoundManager .playOpenGui (p );
224241 }
225242
0 commit comments