File tree Expand file tree Collapse file tree
src/main/java/me/kodysimpson/simpapi/menu Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77 <groupId >me.kodysimpson</groupId >
88 <artifactId >SimpAPI</artifactId >
9- <version >4.1.4 </version >
9+ <version >4.1.5 </version >
1010 <packaging >jar</packaging >
1111
1212 <name >SimpAPI</name >
Original file line number Diff line number Diff line change 1919public abstract class Menu implements InventoryHolder {
2020
2121 //Protected values that can be accessed in the menus
22- protected PlayerMenuUtility pmu ;
22+ protected PlayerMenuUtility playerMenuUtility ;
2323 protected Inventory inventory ;
2424 protected ItemStack FILLER_GLASS = makeItem (Material .GRAY_STAINED_GLASS_PANE , " " );
2525
2626 //Constructor for Menu. Pass in a PlayerMenuUtility so that
2727 // we have information on who's menu this is and
2828 // what info is to be transferred
29- public Menu (PlayerMenuUtility pmu ) {
30- this .pmu = pmu ;
29+ public Menu (PlayerMenuUtility playerMenuUtility ) {
30+ this .playerMenuUtility = playerMenuUtility ;
3131 }
3232
3333 //let each menu decide their name
@@ -55,7 +55,7 @@ public void open() {
5555 this .setMenuItems ();
5656
5757 //open the inventory for the player
58- pmu .getOwner ().openInventory (inventory );
58+ playerMenuUtility .getOwner ().openInventory (inventory );
5959 }
6060
6161 //Overridden method from the InventoryHolder interface
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ public void setData(String identifier, Object data){
3232 this .dataMap .put (identifier , data );
3333 }
3434
35+ public void setData (Enum identifier , Object data ){
36+ this .dataMap .put (identifier .toString (), data );
37+ }
38+
3539 /**
3640 * @param identifier The key for the data stored in the PMC
3741 * @return The retrieved value or null if not found
@@ -40,5 +44,31 @@ public Object getData(String identifier){
4044 return this .dataMap .get (identifier );
4145 }
4246
47+ public Object getData (Enum identifier ){
48+ return this .dataMap .get (identifier .toString ());
49+ }
50+
51+ public <T > T getData (String identifier , Class <T > classRef ){
52+
53+ Object obj = this .dataMap .get (identifier );
54+
55+ if (obj == null ){
56+ return null ;
57+ }else {
58+ return classRef .cast (obj );
59+ }
60+ }
61+
62+ public <T > T getData (Enum identifier , Class <T > classRef ){
63+
64+ Object obj = this .dataMap .get (identifier .toString ());
65+
66+ if (obj == null ){
67+ return null ;
68+ }else {
69+ return classRef .cast (obj );
70+ }
71+ }
72+
4373}
4474
You can’t perform that action at this time.
0 commit comments