[SOLVED] Stopping [WARNING]-Console Spam & question regarding setAllowFlight()

Discussion in 'Plugin Development' started by bassfader, Jan 25, 2012.

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


    Hi there,

    I am developing a Plugin especially for my server. One of its purposes is to allow flying for certain players, but not all players. (Can be triggered by a command for any player at "runtime")

    So in the server.properties file I've set allow-flight to false, and I am running Player.setAllowFlight(true) for every player who should be allowed to fly.

    Then I've hooked into the PlayerKickEvent and cancelled it if Player.getAllowFlight() returns true. This works pretty well, but I have one "problem" (or better inconvenience) that really disturbs me:
    When someone (who is allowed to fly) is flying, the Console soon gets spammed with the "[WARNING] XXX was kicked for floating too long!" message, even though I've cancelled the event (which works, as the player isn't kicked).

    So now my main question is: Is it possible to prevent the Console getting spammed with that message? Can I somehow prevent it from beeing sent? I went through the API but couldn't find anything regarding this... Any help is really appreciated!

    Also I've got another question: In the description for Player.setAllowFlight() it says: "Sets if the Player is allowed to fly via jump key double-tap like in creative mode"
    But this won't work for me somehow. Do I have to enable "allow-flight" in the server.properties for this to work? (That really would be a pitty as I need to keep it disabled so people who are not allowed to fly don't use client mods to do so)

    (I am using the AdminCmd Plugin anyways which has a fly command which works pretty well so this is not a big issue for me... Though it would be much more handy to just double-tap the spacebar instead of having to type /fly each and every time :rolleyes:)

    CraftBukkit Version: 1.1-R1
    BukkitAPI Version: Latest (downloaded today: bukkit-1.1-R1-20120124.205229-48.jar)

    Okay so I think I found a solution for the first problem (stopping specific messages from beeing logged). I just parsed through the API again and thought getServer().getLogger() might be just what I am searching for :) Will give that a try when I am coming home, but it looks very promising because it seems like its a basic Java Logger, which can be filtered.

    Though my other question is still open: If I run setAllowFlight(true) on some player, why can't he just double-tap the spacebar to start / stop flying? Do I have to enable the "allow-flight" in the server.properties for this to work?

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


    Can't you just set the player's gamemode to 1?
  3. Offline


    First of all, thanks for you input, any help is really appreciated :)

    Technically this could work for flying, but then people would also be able to have the "infinite inventory" thing and all the other stuff from the Creative mode, which I don't want.

    The Bukkit Docs told me: "Creative mode may fly, build instantly, become invulnerable and create free items"
    But my goal is to allow flying only, without invulnerability or free items...

    Or is it possible to block the other features somehow?
  4. Offline


    Nope, it's not possible.
    Also, it's not possible to make the double-tap flying without creative mode, as far as I know.
    Your users would need a client flying mod for your plugin to work.

    Also, for your message problem - can you try event.setCancelled(true) and either:
    event.setReason("") and event.setLeaveMessage("")?
    event.setReason(null) and event.setLeaveMessage(null)?
    bassfader likes this.
  5. Offline



    Thanks again for your input! I guess then I'll have to deal with that... Bummer... But well then people have to type /fly if the want to fly (and are allowed to do so) and I'll have to give and take permissions for using this command. A bit of a hassle but well... Gotta live with it ^^

    About the messaging problem: Definately going to give that a try, why didn't I think of something like that :oops: And if that doesn't work I guess setting a Filter on the ServerĀ“s Logger should do the trick at least. Going to try that when I come back home from work today.

    Thank you :)

    Just gave it a try, but unfortunately this doesn't work. But as I mentioned before I also had an Idea involving java.util.logging.Logger, and it worked :) If anyone is interested in how I did this, I am going to give you a very short example :

    I just had to create a class which implements java.util.logging.Logger and create my filter there. Heres a very simplistic filter class:
    package de.stonedCRAFT.stonedCRAFT_Suite.Logger;
    import java.util.logging.Filter;
    import java.util.logging.LogRecord;
    public class 
    suiteLoggerFilter implements Filter {
    public boolean isLoggable(LogRecord arg0) {
            return !
    arg0.getMessage().contains("was kicked for floating too long!");
    Then I justed needed to set that filter on the Server Logger in my onEnable() function like this:
    getServer().getLogger().setFilter(new suiteLoggerFilter());
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 23, 2016
  6. Offline


    You saved me plenty of time.
  7. Offline


    You're welcome :D
Thread Status:
Not open for further replies.

Share This Page