/tpa - How ?

Discussion in 'Plugin Development' started by MinesnHD, Jun 22, 2014.

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

    MinesnHD

    I thought i can make a /tpa Plugin with a boolean, but the boolean is Public and would be for everyone, and i know that there is an easier way to do this. Please help <.<

    /tpa <player> -> Sends a teleport request to the specific player and he can accept or deny
     
  2. Offline

    hankered

    MinesnHD

    Use configs or hashmaps i'd assume.
     
  3. Offline

    TheHandfish

    We're going to need your code and any errors you're getting to help you out.
     
  4. Offline

    jimuskin

    MinesnHD On command, add a player to a Hashmap, which when they tpaccept, get the player who originally sent the tpa request (which is stored in the hashmap) and teleport them
     
  5. Offline

    spy_1134

    Code:java
    1. Map<String,String> requests = new HashMap<String,String>();
    2.  
    3. //When a player requests to teleport to another player, add them like so:
    4. requests.put(requester,target);
    5.  
    6. //To see if someone has requested to teleport to you:
    7. requests.containsValue(yourname)
    8.  
    9. //To get the name of the player who requested to teleport to a player: (returns null if no one found)
    10. public String getNameOfRequester(String targetName) {
    11. for(Entry<String, String> entry : requests.entrySet()) {
    12. if(entry.getValue().equals(targetName)) {
    13. return entry.getKey();
    14. }
    15. }
    16. return null;
    17. }
    18.  


    You should look up more about HashMaps, they are really useful. Lists and arrays too if you don't know how to use those.
     
Thread Status:
Not open for further replies.

Share This Page