How can I create a /pm Command??

Discussion in 'Plugin Development' started by Nico4898, Nov 11, 2013.

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

    Nico4898

    Hi there,
    I want to make the same command like in the Plugin Chathero , but I don't know how :oops:.
    Can I do that with HashMaps??
    Would be nice if you could give me an example-code for this :)
     
  2. Offline

    xTrollxDudex

    Nico4898
    Add a pm command to your onCommand method and store the target and the sender on a HashMap, and when the target does /r check the sender on the HashMap and send the arguments to him.
     
  3. Offline

    mattrick

    Nico4898
    Also would likely have to save messages to a yml file or SQL server to stay through reloads.
     
  4. Offline

    Nico4898

    ok could you give me an example code for this please? :)
     
  5. Offline

    xTrollxDudex

    No. If you need basic code go back to the plugin tutorial on the wiki.
     
    maxben34 and drtshock like this.
  6. Offline

    Myst3ryKid

    So, hashmap<Player, Player>
    when they message. go [your hashmap].put(player, target); and [your hashmap].put(target, player);
    In the reply get the [your hashmap].get(player); Its gets what the player on there data in the hashmap, understood?
     
  7. Offline

    Cirno

    It's recommended that you use HashMap<String, String> and store the players' name.
     
  8. Offline

    Myst3ryKid

    You could, I personally would use Player, if you wanted there name you could just go hashmap.get(p).getName();
    :D lol
     
  9. Offline

    maxben34

    If I remember correctly, you never want to use Player in a hashmap... you always want to use string. I don't remember why but it might b cuz of memory leaks.
     
  10. Offline

    Myst3ryKid

    Really? I have been using Players in hashmaps forever, whatever :p I have never had an issue
     
  11. Offline

    maxben34

    I could be wrong. I use player myself :3
     
  12. Offline

    xTrollxDudex

    Myst3ryKid
    Click on ---> ferrybig

    Click on his avatar when the pop up renders, go to the "information" tab and open the spoiler to his signature.
     
  13. Offline

    Myst3ryKid

    ah >.> well if your only replying.. it will be ok
     
  14. Placing a Player inside a hashmap is a high risk operation, bukkit does not say what the hashcode of a player must be, means you can have thousands of player objects inside your list, without knowing it, see me signature for the problems about the memory leaks:
     
  15. Offline

    callum.thepro

    I was hoping you would show up with your signature.
     
Thread Status:
Not open for further replies.

Share This Page