Solved Storing Player name during command usage.

Discussion in 'Plugin Development' started by Gosintary, Jul 14, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Gosintary

    Hello!

    I'm currently working on a punishment GUI plugin.

    I have a command where staff members do /punish {player name} and it opens a GUI with four categories.
    They then choose the category of rule that was broken which opens a new GUI, where the staff member then picks the rule that was broken. After the staff member clicks said rule the plugin executes the proper punishment command on their behalf (using Bukkit.executeCommand()).

    What I'm currently doing is storing the name of the player in the argument as a public variable during command execution. I have no problems doing that. HOWEVER, if another staff member attempts to punish someone else while one staff member already has the GUI open, the variable changes when the second staff member does the command and whatever punishment the first staff member chooses is given to the player the second staff member is attempting to punish.

    How would I go about storing the args[0] from my onCommand method for use in my switch statement that I'm using to manage inventory clicks, that would allow multiple different args[0]s to be store at the same time?

    EDIT:

    I'm an idiot.

    Code:
    public HashMap<Player, Player> tlist = new HashMap<Player, Player>();

    Code:
    Player p = (Player) s;
    Player t = Bukkit.getPlayer(args[0]);
                         
    tlist.put(p, t);

    Code:
    Player p = (Player) e.getWhoClicked();
    Player t = tlist.get(p);
     
    Last edited: Jul 14, 2020
Thread Status:
Not open for further replies.

Share This Page