Solved Disable the output of a specific command in the console

Discussion in 'BungeeCord Plugin Development' started by Tristiisch74, Jan 28, 2020.

  1. Hello,

    I want to remove
    Code (Java):
    Tristiisch executed command: /login
    in bungeecord console.

    I've tried this:
    Code (Java):
    ProxyServer.getInstance().getLogger().setFilter(new HandlerHideLogin());
    Code (Java):
    public class HandlerHideLogin implements Filter {

        public static List<String> command = new ArrayList<>();

        @Override
        public boolean isLoggable(LogRecord record) {
            System.out.println("DEBUG commands: " + String.join(", ", command) + " MSG " + record.getMessage() + " name " + record.getLoggerName());
            return !command.stream().anyMatch(cmd -> record.getMessage().contains("executed command: /" + cmd));
        }

    }
     
    Note: The list command is not empty, it contains /login, /register ...

    But it dosen't work; this is the debug message:
    Code (Java):
    DEBUG commands: login, register MSG {0} executed command: /{1} name BungeeCord
     
    This method dosen't give me the command name.

    So, Filter the Logger dosen't work for me.
    I don't wan't to remove every command output, I known I can do it easly in config.yml.
    Thanks in advance.
     
  2. I once used sfl4j for something similar to this, but that was in spigot. You could try it with bungeecord though.
     
  3. Filters doesn't work because bungeecord is using formatter to log these things (see this) and that when the filter is called the message is still not being formatted. The solution here is to use slf4j and to make a filter that forwards all messages to slf4j logger (basically what waterfall's doing, you're going to accomplish this easier by using waterfall as your server software as you have Plugin#getSLF4JLogger)
     
  4. the WaterFall API adds possibilities on the plugin side? I didn't know, I already use it for my servers but not in code. I did some research on a maven repo but I couldn't find it, do you have it please?

    And thanks @Valkyy & @MrIvanPlays, thread is solved, I think.
     
  5. You add the papermc repo and the waterfall dependency
     
  6. Ok, I couldn't figure out how to filter properly with slf4j. Could someone point me in the right direction ?
     
  7. I've solved it with event ChatEvent and cancel it.