PlayerEvent when a server shuts down ?

Discussion in 'Bukkit Help' started by Sushen, Oct 18, 2011.

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

    Sushen

    Hi,

    I'm trying to make precise connection logs of the players who join my server.
    More precisely, i want to know the mean time they spend on my server ; so i want to log when they arrive, and when they leave.

    The problem is that when the server shuts down from the console, no player event is sent !
    How can i know when the server shuts down, so i can add to my logs that the connected players where forced to disconnect ?

    Thank you
     
  2. Offline

    Don Redhorse

    there is an event... look at message changer light or message changer source code to see it is / was handeled.
     
  3. Offline

    Sushen

    Thanks a lot. Works like a charm ;)



    Code:
    public void onDisable()
    { 
        if (isServerShuttingDown())
        {
            // do stuff
        }
    }
    
    
    private boolean isServerShuttingDown()
    {
        StackTraceElement[] st = new Throwable().getStackTrace();
        for (int i = 0; i < st.length; i++)
        {
            if (st[i].getMethodName().equals("stop"))
                return true;
        }
        return false;
    }
     
  4. Offline

    Sushen

    Well, doesn't work so good :(
    Works fine on a local server, but not on the distant one..
    Facts are that when the server shuts down, people loose their connection BEFORE the unload of the plugin.

    They receive the following message :
    In the server.log file, the following line appears :
    The stack trace is ok..
    Any way i can plug myself sooner on a server shutdown ?
    Thanks
     
  5. Offline

    mrvertigo27

    you can always get a plugin that kicks all players online to run before a restart. this may suit your needs. I have seen these floating around.
     
  6. Offline

    Sushen

    You mean manually, right ?

    Well, the most part of the problem is that my game server provider gives me only access to a restricted web manager with a restart and stop button, so i can't plug myself before the server shutdown command is sent.

    If i call the /stop command ingame, everythings fine (my code works perfectly, and kicks before) .. but if i use the webmanager, it doesn't..... (i still didn't understand what exactly my provider does for his shutdown process - really strange) ..

    But kicking my players manually - even with a shortcut command - is exactly what i don't want to do ... i'm looking for an automated process, as i won't have a minecraft client anytime with me - sometimes, i'll have to use the webmanager ONLY.


    If you're talking about plugins that do the stuff automatically, i'm interested of course !!
    But i don't think they exist - i've searched a bit before and parsed lot of code, with no luck.
     
  7. Offline

    mrvertigo27

    well using something like CommandHelper you could script a special stop command that licked all players with the messaage (restarting please wait 2 minutes to reconnect) then the script would execute the stop command for you after it kicks you :p
     
  8. Offline

    Sushen

    You certainly misunderstood me ^^
    I just said i won't be in game somtimes to administrate my server, but rather use a webpage from my hoster's site :)
    So ur solution is useless in my case ;)
     
  9. Offline

    mrvertigo27

    but can you issue commands via terminal on that interface? if not im out of ideas.....
     
  10. Offline

    Sushen

    No, i can't. The webpage only displays 2 buttons "Restart" and "Stop", player management stuff, and some map configuration options .... (yeah, that' pretty poor, i know)
     
Thread Status:
Not open for further replies.

Share This Page