Avoid Log Spam onPlayerKickEvent?

Discussion in 'Plugin Development' started by Soxra, Mar 25, 2012.

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

    Soxra

    Hey,
    this is my new plugin http://forums.bukkit.org/threads/ge...mode-for-survivals-hovering-1-2-4-r0-1.66934/
    There you can enable fly-mode for survival players. But if flying is not enabled they get kicked. So i have tried to avoid this kick with
    if event.getReason().equalsIgnoreCase("Flying is not enabled on this Server")
    event.setCanceled(true);

    Now the log Spams with the kick information evry millisecond. What can i do to avoid this?

    Regards Soxra.
     
  2. Offline

    Eegabooga

    I've never used PlayerKickEvent before, but try event.setLeaveMessage("").
     
  3. Offline

    Soxra

    Thanks, will try this.

    Eegabooga
    This is not working. Anyone else have an idea?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  4. Offline

    nicholasntp

    Try priority MONITOR.
     
  5. Offline

    Soxra

    Like this? i dont understand...
    Code:
    @EventHandler(priority=EventPriority.MONITOR)
    public void onPlayerKick(PlayerKickEvent event){
    avoid log spam
    }
     
  6. Offline

    nicholasntp

    Code:java
    1.  
    2.  
    3. @EventHandler(priority = EventPriority.MONITOR)
    4. public void onPlayerKick(PlayerKickEvent event){
    5. if (event.getReason().contains("Flying is not")) {
    6. event.setLeaveMessage("")
    7. event.setCanceled(true);
    8. }
    9. }
    10.  
    11.  
     
  7. Offline

    Soxra

    Not working ... :(
     
  8. Offline

    nicholasntp

    Hmm... let me think...

    Have you ever considered setting allow-flight to true in properties file?

    EDIT: You can have the plugin (in the OnEnable) check if allow flight is disabled, and if it is, tell the console and disable the plugin so it doesnt kick.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  9. Offline

    Soxra

    I want certain players to be avoidd.
     
  10. Offline

    nicholasntp

    From what, the kick?
     
  11. Offline

    ItsHarry

    Maybe you should do it differently, keep allow-flight=true
     
  12. Offline

    nicholasntp

    Kinda what I said.... lol. No problem tho.
     
  13. For each player you could do

    player.setAllowFlight

    I am doing this from memory so it night not be 100% correct.
     
  14. Offline

    Soxra

    This just toggles the flymode on ;)
     
  15. Offline

    confuzzled77

    I think the newest dev version of bukkit won't spam it. Check version 2118 and above.
     
  16. Offline

    MCForger

    Why dont you just say event.setkickmessage("Flying is not allowed!")?
    Wouldnt that be easier then spamming the chat with one message?
     
Thread Status:
Not open for further replies.

Share This Page