Overriding Bukkit method

Discussion in 'Plugin Development' started by MadJawa, Aug 8, 2011.

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

    MadJawa

    Hi,

    I'd like to know if it's possible to override a bukkit server function. What I want to do is override bukkit's getOnlinePlayers to remove someone from the list. Is this kind of thing possible in Java?
     
  2. Offline

    Darkman2412

    CraftBukkit handles the getOnlinePlayers() and I think that it's not possible to override it.
     
  3. Offline

    Shamebot

    You could alter the list the server gets the players from, but I don't know if that's a good idea.
    Code:java
    1. ((CraftServer)Bukkit.getServer()).getHandle().players

    Or look at some sources from plugins making players invisible (Spyer), they may do something similar.
     
  4. Offline

    Darkman2412

    Can't you just use
    Code:java
    1. this.getServer().getOnlinePlayers();
     
  5. Offline

    Shamebot

    No, CraftBukkit takes the players from the list and puts them in a array, when you change this array nothing will happen, whenever you call .getOnlinePlayers() again it will return you a new array.
     
Thread Status:
Not open for further replies.

Share This Page