Getting a Player from a different class

Discussion in 'Plugin Development' started by migsthegod, Apr 26, 2012.

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

    migsthegod

    Hi there, i'm new and i've tried searching google on what to do but i think my problem is too specific.

    So i have this in class ABC:
    Code:
     //ABC
    HuntWorld world = HuntWorldManager.getWorld(((Player) sender).getWorld().getName());
     
     
    if (world.Score.containsKey(((Player) sender).getName()))
    What i want to do is get:
    Code:
    (world.Score.containsKey(((Player) sender).getName()))

    and insert it into class 123:
    Code:
    //123
    Player player = ??? // i want to insert it here
     
                              player.teleport(Arenas.getCenter("111"));
                              player.sendMessage("Teleported!");
    

    I've tried something like:
    Code:
    //ABC class
    String test = String.valueOf(world.Score.containsKey(((Player) sender).getName()));
     
    //123
    Player player = Bukkit.getPlayer(test);
    but it doesnt work and i cant seem to find a solution for it.

    Any help would be greatly appreciated :)
     
  2. Offline

    Njol

    You're looking for a player called "true" or "false", depending on whether the Score (whatever that is) contains the player or not.
    Also we have no clue how your classes are linked (you can use their actual names btw, it makes it easier to understand) and what you wnat to do with it, so I can't help you at all.
     
  3. Offline

    Giant

    Minor question, why not store a reference to the Player instance you obviously already have in ABC, and then obtain it via a getter or such.
     
  4. Offline

    Lolmewn

    You can use Bukkit.getServer().getPlayer("Name");
     
Thread Status:
Not open for further replies.

Share This Page