Adding features to the org.bukkit.entity.Player class?

Discussion in 'Plugin Development' started by Jaker232, Feb 29, 2012.

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

    Jaker232

    I'm working on a plugin, while the other is on hold right now and I'm curious how I can implement the Player class in org.bukkit.entity so I can add new methods to the Player instance.

    However, doing it on "extends" I can not find it. However, doing 'implements' would cause the class to spam up with methods that return no value (all Player methods) and I do not want that.

    Is there a loophole I can use to get past this?
     
  2. Offline

    Digi

    Well, what exacly are you trying to add ? And why add it to the existing Player class ?
     
  3. Offline

    Jaker232

    I'm working on a plugin that does check the uptime of a player and I need to know how to extends the Player class so I can add a few variables and methods.
     
  4. Offline

    DrBowe

    You're going to want to use a Player Wrapper for this, as 'extending the Player class' really isn't an easy task to accomplish.
     
  5. Offline

    Taco

    class MyPlayer extends Player
    {

    Player realPlayer;
    MyPlayer(Player p)
    {
    realPlayer=p;
    }

    MyPlayer(String s)
    {
    try{
    realPlayer=Bukkit.getPlayer(s);
    } catch(Exception e) {}
    }

    Player getPlayer()
    {
    return realPlayer;
    }

    }

    That should be a start. You'd construct a MyPlayer object rather than a Player object. Keep in mind that this is just written out from school and it may not work. I'm not sure that Player is a class that can be extended actually.
     
  6. Offline

    nisovin

    A metadata system has also recently been added. You can use getMetadata and setMetadata to add data to a Player object. I haven't actually used it myself yet, but it is in there.
     
    Digi likes this.
  7. Offline

    DrAgonmoray

    wat? :D is it really here?
     
  8. Offline

    Jaker232

    No.
    Fucking.
    Way.

    Please kick me to Mars.
     
Thread Status:
Not open for further replies.

Share This Page