HashMaps Help

Discussion in 'Plugin Development' started by bubblefat_, Jun 2, 2015.

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

    bubblefat_

    I am making a mute command. I need to know how to store a players username and the Reason in a HashMap
    Reason (open)

    Code:
    String reason = "";
    for (int i = 1; i != args.length; i++)
    reason += args + " ";


    Then from a different class how to get the players name and the reason.
     
  2. Offline

    justin_393

    Make a HashMap that stores a UUID and String
    HashMap<UUID,String> mutes = new HashMap<UUID, String>();
     
  3. So it should be:
    Code:
    public Map<UUID, String> mutedPlayers = new HashMap<>();

    Anyway, in general, bubblefat_, it seems you don't really know the basics of Java, I'm not trying to offend you, but Map is a key Java feature, as well as the "public" modifier, along with for example, the "static" modifier.
    http://docs.oracle.com/javase/tutorial/

    You should try learning about all of this before creating Bukkit plugins, otherwise the forums gets spammed with threads asking basic questions.

    Example of errors: "i != args.length"
    Use: i < args.length

    "String", use a StringBuilder, it's more efficient in loops.
     
    Last edited: Jun 3, 2015
Thread Status:
Not open for further replies.

Share This Page