Change the number of players sent in ServerListPingEvent

Discussion in 'Plugin Development' started by vildaberper, Feb 14, 2012.

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

    vildaberper

    Since there's no official method I though I could just make the field accessable like so:
    Code:
    try{
        online = ServerListPingEvent.class.getDeclaredField("numPlayers");
        online.setAccessible(true);
    }catch(Exception e){
        e.printStackTrace();
    }
    declaring the field like this in my main class:
    Code:
    public Field online = null;
    and setting it when the event is fired:
    Code:
    @EventHandler
    public void onServerListPing(ServerListPingEvent event){
        try{
            online.setInt(event, getOnlinePlayers());
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    but still, no luck. I even checked the field with debug messages, and it has the right value. It's just not that value which is beeing sent to the users serverlist.

    Any ideas?
     
  2. Offline

    nisovin

    That field is not intended to be set, so CraftBukkit does not check it. You can't do this, sorry.
     
  3. Offline

    neol3108

    Your code works for me?
    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page