Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.UUID;

/**
* Used to interface with the Menu Manager API
*/
public class MenuManager {

//each player will be assigned their own PlayerMenuUtility object
private static final HashMap<Player, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
private static final HashMap<UUID, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
private static boolean isSetup = false;

private static void registerMenuListener(Server server, Plugin plugin) {
Expand Down Expand Up @@ -70,15 +71,15 @@ public static PlayerMenuUtility getPlayerMenuUtility(Player p) throws MenuManage
}

PlayerMenuUtility playerMenuUtility;
if (!(playerMenuUtilityMap.containsKey(p))) { //See if the player has a pmu "saved" for them
if (!(playerMenuUtilityMap.containsKey(p.getUniqueId()))) { //See if the player has a pmu "saved" for them

//Construct PMU
playerMenuUtility = new PlayerMenuUtility(p);
playerMenuUtilityMap.put(p, playerMenuUtility);
playerMenuUtilityMap.put(p.getUniqueId(), playerMenuUtility);

return playerMenuUtility;
} else {
return playerMenuUtilityMap.get(p); //Return the object by using the provided player
return playerMenuUtilityMap.get(p.getUniqueId()); //Return the object by using the provided player
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@
Each player has one of these objects, and only one.
*/

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.Stack;
import java.util.UUID;

public class PlayerMenuUtility {

private final Player owner;
private final UUID owner;
private final HashMap<String, Object> dataMap = new HashMap<>();
private final Stack<Menu> history = new Stack<>();

public PlayerMenuUtility(Player p) {
this.owner = p;
this.owner = p.getUniqueId();
}

public Player getOwner() {
return owner;
return Bukkit.getPlayer(owner);
}

/**
Expand Down