Solved Requests

Discussion in 'Plugin Development' started by MasterDoctor, Sep 1, 2014.

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

    MasterDoctor

    I am looking for a way to code this (it is a little like essentials /tpa):
    When a player enters a command, it sends a request to another player who can accept/deny,
    When the player accepts/denies it runs code.
     
  2. Offline

    Jace_oio

    You could allways use HashMaps ;)

    hint: Map<String, String> currentRequest = new HashMap<String, String>();

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  3. Offline

    MasterDoctor

    I'm not sure how to use Hash Maps.
     
  4. Offline

    dchaosknight

  5. Offline

    JBoss925

    MasterDoctor

    Knowing Java is a beautiful thing, you know.
     
  6. Offline

    MasterDoctor

    In fact I have no idea :eek:

    ik, Sorry people!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  7. Offline

    JBoss925

    MasterDoctor Well, nonetheless, go learn some java and come back and you'll understand these steps.

    1) Create a hashmap that stores a UUID key and UUID value.

    2)When the player sends the /tpa command, check if the first argument is "accept" or "deny". If so, see step 4. If not, parse the first argument and find the player, let's call him p.

    3)Now put the key of the hashmap as the sender's UUID and the value as the first argument, p's, UUID. It's over for now.

    4)If you're getting to this step, that means the first argument was "accept" or "deny". If it is "accept" see step 5, if it is "deny" see step 6.

    5) Since the first argument is "accept", get the entrysets of the hashmap then use the value and see if it matches the sender's UUID, if so get the key, parse the player and teleport the value to him after you have parsed the value to a player. Send any confirmation messages you want.

    6) Since the first argument is "deny" get the entrysets of the hashmap then use the value and see if it matches the sender's UUID, if so get the key, parse the player and send him an deny message. Then remove that entry from the hashmap.
     
  8. Offline

    MasterDoctor

    OK, I learnt about HashMaps and it really helps.
    For those who don't know about hasmaps, this video by thebcbros really helped:

    Again, Thanks for helping me out!
     
    JBoss925 likes this.
  9. Offline

    ChipDev

    2 weeks ago: What the heck.. I keep saying I want to learn hash maps just its too hard and lol there are <>'s PANIC MODE!

    now: Ok, Just like an array list ;)
     
    MasterDoctor likes this.
  10. Offline

    MasterDoctor

    Me Too! Only difference is:
    45 mins ago: HELP!!!
    Now: Oh, Another Hash Map
     
    ChipDev likes this.
  11. Offline

    ChipDev

    Lawl.
     
Thread Status:
Not open for further replies.

Share This Page