Plugin just stops working

  • What would cause a plugin to just stop? I have a plugin that assigns a few keys for special instructions. The plugin works for about 30 minutes then suddenly stops. The keys become unregistered. If I reload the plugins with RP then they work again.
    They are not assigned as attributes for the player maybe I need to do that is possible but I am not sure what causes the plugin suddenly to not work anymore. Any ideas?

  • without the full code no clue unfortunately :/


    code in general doesn't just stop working because it decides to do so, there must be either an error causing it to stop functioning or some other problem there :/


    also if it is always at exactly 30 minutes then it is definitely an error in the code, such consistency is not common for small random bugs

  • without the full code no clue unfortunately :/


    code in general doesn't just stop working because it decides to do so, there must be either an error causing it to stop functioning or some other problem there :/


    also if it is always at exactly 30 minutes then it is definitely an error in the code, such consistency is not common for small random bugs

    Always the same response... I have not seen code suddenly stop before unless something else is changing parameters. Unfortunately I cannot restart just the one plug in I have to restart them all.


    Well the 30 minutes seems to be imprecise. It is a keypress routine that gets the current day. I was trying to test the capabilities as well as get the moonphase but not sure about finding that so went back to day. No player has spawned on the server during the time but there area allot of con commands such as weather and health. So the question is can a key register become unregistered? It does look to see if I am Admin.

  • Always the same response... I have not seen code suddenly stop before unless something else is changing parameters. Unfortunately I cannot restart just the one plug in I have to restart them all.

    well unfortunately this is how it is, and without being able to see the actual code that might be causing the error there is no way to debug.


    Imagine I told you I have a painting and I don't like how blue the sky is on it and want advice on changing it. Then I describe it as blue and say I don't think the shade fits very well and expect your opinion without showing the actual painting to you. How would you know if I have to make it lighter, darker, or leave it as is? You can't possibly give an opinion based on my explanation of what is there without seeing it :/ The same applies to code, without the full script I can't possibly tell what could cause your keys to unregister or your plugin to crash.

    So the question is can a key register become unregistered?

    To that the answer is simple. No. Unless you unregister it via the plugin there is no way for it to just decide "I don't like being registered let's quit". It just can't happen unless the whole game's internal methods crash and all hell breaks loose. Maybe red's code is not as robust as Google's or Facebook's (not saying it isn't just a maybe for the sake of the argument) to never experience issues but still it is not like the game has tonnes of serious destructive bugs or breaks down every few minutes.


    PS: it is not like I am on purpose trying not to help you out, but without actual information it is not easy to just guess about these things :/

  • Fair enough. Well looking at it. It cant be the admin because I dont check for that on this if statement . For it to work consistently on two servers that long . It could be possible another listener plugin is causing it. The problem of looking at the test server is it is not under stress with things being placed and movement. If it works once I cannot imaging a simple I did not check if the X key was mapped in the server... I know when I used the Q i both activated it and threw away what I was holding :rolleyes:



    public void onPlayerSpawnEvent (PlayerSpawnEvent event){
    Player player = event.getPlayer();
    player.registerKeys(KeyInput.KEY_X);
    player.setListenForKeyInput(true);
    server = getServer();
    }


    @EventMethod
    public void onPlayerKeyEvent (PlayerKeyEvent event){
    Player player = event.getPlayer();
    //// some if statement similar looking for R.. that has nested Admin check////
    /// no admin check for X////
    if(event.getKeyCode()== KeyInput.KEY_X ){
    player.sendTextMessage("current Game Day = "+ gdays);
    }



    What happens is neither X nor R will work until a 'RP' plugin reload

  • It could be possible another listener plugin is causing it.

    plugin listeners are independent, i.e. if two plugins are listening for the same key then when the key is pressed both plugins will receive the event and do whatever they should do with that key. Another plugin cannot interfere with your plugin in such a way at least.

    /// no admin check for X////

    what do you mean by admin check for X? just a line if (player.isAdmin())? or how do you check the key against a player being an admin?


    I just copied the code you posted and tested it on my world and it works as it should, so your problem must be somewhere else in the plugin.


    PS: without using the event.isPressed() method in the PlayerKeyEvent the method's code is triggered twice, once on press and once on release of the key

  • Yes I have tried it both ways it was really just a testing routine for me to figure out how to grab things with keypresses.


    yes I guess i did not copy that part about the day.


    int gdays = server.getGameTime(Time.Unit.Days);


    Yes when the R is pressed under the detection I have if (player.isAdmin()){


    I dont do that for the X key.


    Well it worked and failed the same again after an hour or so of building things..

  • Seperate question Minos.. I am so used to making things happen on events.. I want it to run even when there are no players on can I just use onEnable are is there a better spot to put the code?

  • Well it worked and failed the same again after an hour or so of building things..

    hmm are you using unregisterKeys() anywhere in your code? Then the problem is obviously not caused by the two methods you posted above, it must be somewhere else in the plugin :/

    Seperate question Minos.. I am so used to making things happen on events.. I want it to run even when there are no players on can I just use onEnable are is there a better spot to put the code?

    What exactly you want to run even when no player's are online? onEnable is only called once when the plugin/server starts it is never called again. It is used to initialise things the plugin needs to function so you could set a timer to check something every few seconds if that is what you need. Can you explain what you want to do in more detail? Then I will be able to help more :/

  • hmm are you using unregisterKeys() anywhere in your code? Then the problem is obviously not caused by the two methods you posted above, it must be somewhere else in the plugin :/

    What exactly you want to run even when no player's are online? onEnable is only called once when the plugin/server starts it is never called again. It is used to initialise things the plugin needs to function so you could set a timer to check something every few seconds if that is what you need. Can you explain what you want to do in more detail? Then I will be able to help more :/

    • No the code is exactly that one simple set of codes .. there is nothing big about it. As I said it is a testing code I will build upon it later but it has been running in background until I can expand upon it. the Plugin sets up 2 keys and says you pushed the key and this is the game date. The first key is admin only and now looks for admin and sends out a 10 distanct raycast and returns the NPC type. It was just recently modified to show a player but it had the disappearing act before it was changed.. TWO KEYS that is it simple testing nothing fancy.
    • LOL I want to keep track of the days and handle some under the table continuously changing game mechanics. You pretty much answered it. Thanks
  • No the code is exactly that one simple set of codes .. there is nothing big about it. As I said it is a testing code I will build upon it later but it has been running in background until I can expand upon it. the Plugin sets up 2 keys and says you pushed the key and this is the game date. The first key is admin only and now looks for admin and sends out a 10 distanct raycast and returns the NPC type. It was just recently modified to show a player but it had the disappearing act before it was changed.. TWO KEYS that is it simple testing nothing fancy.

    hmm ok well as I said before without seeing the actual, full plugin code I have run out of ideas :/ The problem could as simple as one digit or a single letter or a bracket.

    LOL I want to keep track of the days and handle some under the table continuously changing game mechanics. You pretty much answered it. Thanks

    You're welcome :) If you need anything else just let me know :)

  • hmm ok well as I said before without seeing the actual, full plugin code I have run out of ideas :/ The problem could as simple as one digit or a single letter or a bracket.

    You're welcome :) If you need anything else just let me know :)

    Have you tried running your code for an extensive time. Could it be that player is not final? Wierd .. I will just re-initiated the keys I guess if that works over time.

  • well not that specific one no but there is no way for the keys to unregister themselves.


    I know @yahwho has a plugin using quite a few registered keys on his server running without problems.


    Also @yahgiggle has the auto-AreaProtection plugin using registered keys and that plugin too has no problems running indefinitely.


    Then @noci too has created the Teleport plugin that uses registered keys and again has no problem running indefinitely.


    Thus I have to assume the problem lies with your plugin and not the RW API methods as if this was not the case all 3 aforementioned plugins would stop after some time.

  • Alrighty then! you say registered not command so, I will compile and run yours.. I am willing to bet I get the same thing. I am telling you there is nothing different in our codes. I will take the code to my test server and wipe it an check it out.
    I am not going to uplug all the plugins I have rom yagiggle and noci and the like from my main server.


    PS this happens when I am busy placing blocks.. There is only one other Plugin I am activating between blocks and that is your old servertool routine to change the time, heal<feed> me and set the weather while nobody else is on the server. Who knows.. I do like that plug in.

  • PS this happens when I am busy placing blocks.. There is only one other Plugin I am activating between blocks and that is your old servertool routine to change the time, heal<feed> me and set the weather while nobody else is on the server. Who knows.. I do like that plug in.

    placing blocks or using the ServerTools heal, time of day, or weather commands cannot unregister the key. Even if another plugin unregistered the key your plugin will still receive it as input when that key is pressed. The only way your plugin will not receive a key input is if your or another plugin has used the player.disableClientsideKeys(blablabla)

    Alrighty then! you say registered not command so, I will compile and run yours.. I am willing to bet I get the same thing. I am telling you there is nothing different in our codes. I will take the code to my test server and wipe it an check it out.
    I am not going to uplug all the plugins I have rom yagiggle and noci and the like from my main server.

    Tested the code I posted above for 1 hour on my world and it never stopped working.

  • well unfortunately this is how it is, and without being able to see the actual code that might be causing the error there is no way to debug.


    Imagine I told you I have a painting and I don't like how blue the sky is on it and want advice on changing it. Then I describe it as blue and say I don't think the shade fits very well and expect your opinion without showing the actual painting to you. How would you know if I have to make it lighter, darker, or leave it as is? You can't possibly give an opinion based on my explanation of what is there without seeing it The same applies to code, without the full script I can't possibly tell what could cause your keys to unregister or your plugin to crash.

    :thumbsup:



    @angriff
    Have you ever tried out your plugin?
    The snippets in the post 5, copied into a file, are not enough!

    I am telling you there is nothing different in our codes.

    Then you'll have to test the plugins. Start with yours and add the others gradually until you find the culprit ^^.

  • Have you ever tried out your plugin?

    what do you mean if I have ever tried out my plugin? if you are referring to ServerTools yes we run it on our server Artisan's Realm for almost a year now. I am confused :D?(

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!