Skip to content

Commit 5d3a891

Browse files
committed
4.1.5
1 parent 42715f9 commit 5d3a891

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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>

src/main/java/me/kodysimpson/simpapi/menu/Menu.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
public 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

src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)