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


    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:
    HuntWorld world = HuntWorldManager.getWorld(((Player) sender).getWorld().getName());
    if (world.Score.containsKey(((Player) sender).getName()))
    What i want to do is get:
    (world.Score.containsKey(((Player) sender).getName()))

    and insert it into class 123:
    Player player = ??? // i want to insert it here

    I've tried something like:
    //ABC class
    String test = String.valueOf(world.Score.containsKey(((Player) sender).getName()));
    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


    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


    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


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

Share This Page