Filter log message "<player> was kicked for floating too long!"

Discussion in 'Plugin Development' started by Weasel_Squeezer, Jan 6, 2014.

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

    Weasel_Squeezer

    I have some code that launches players into the air if they are falling into the void, but this of course make Minecraft think that players are flying, so I cancel the PlayerKickEvent for these players. However, this for some reason does not cancel the log message sent saying "<player> was kicked for floating too long!". Along with this message, another message is logged by the Minecraft logger which is "<player> lost connection: user was kicked.". This message I was able to filter out using the code below:
    Code:java
    1. String message = " lost connection: user was kicked.";
    2. Logger.getLogger("Minecraft").setFilter(new Filter() {
    3. @Override
    4. public boolean isLoggable(LogRecord record) {
    5. if(record.getMessage() != null && record.getMessage().endsWith(message)){
    6. if (eventListener.getLaunchingPlayers().contains(record.getMessage().replace(message, ""))) {
    7. return false;
    8. }
    9. }
    10. return true;
    11. }
    12. });

    However, the first message I stated does not get logged by the Minecraft logger, and from what I can tell it does not get logged by the Bukkit logger either. I tried this code below, and it does not work:
    Code:java
    1. String message = " was kicked for floating too long!";
    2. getLogger().setFilter(new Filter() {
    3. @Override
    4. public boolean isLoggable(LogRecord record) {
    5. if(record.getMessage() != null && record.getMessage().endsWith(message)){
    6. if (eventListener.getLaunchingPlayers().contains(record.getMessage().replace(message, ""))) {
    7. return false;
    8. }
    9. }
    10. return true;
    11. }
    12. });

    I tried just printing the messages logged by both loggers to standard outprint, but it seems that neither loggers are the ones logging the "<player> was kicked for floating too long!" message. I need to filter out this message because it just spams the log when players are being launched.
    Does anyone know the source of this message?
    I appreciate your help.
     
  2. Offline

    NathanWolf

  3. Offline

    Weasel_Squeezer

    NathanWolf likes this.
  4. Offline

    NathanWolf

    Well I think (/hope) that is a temporary issue with the conversion from 1.6 to 1.7 - Mojang changed the logging class used by Minecraft in 1.7, and I'm thinking once we get to a full RB of 1.7 Bukkit they'll probably have switched over.

    Mojang is certainly keeping the Bukkit team on their toes lately, I wouldn't want to be in their shoes right now, honestly :\
     
  5. Offline

    Weasel_Squeezer

    Wait I have one question.
    The fix that was found in that thread casted log4j classes, but I cannot import any log4j class with the package name "org.apache.logging.log4j" because the log4j classes do not exist in Bukkit or Craftbukkit jars, and the actual log4j source has the package name of "org.apache.log4j". How did they get that code to compile then?
    EDIT: well I'm dumb. log4j was a new change Minecraft, and I forgot that I wasn't updating craftbukkit on my machine since I am using spigot... Nevermind!
     
Thread Status:
Not open for further replies.

Share This Page