Skip to content

Instantly share code, notes, and snippets.

@WizardlyBump17
Created April 10, 2021 16:48
Show Gist options
  • Save WizardlyBump17/35038b97497dc8e91fcc83bc4667e752 to your computer and use it in GitHub Desktop.
Save WizardlyBump17/35038b97497dc8e91fcc83bc4667e752 to your computer and use it in GitHub Desktop.
package com.wizardlybump17.imperiumphones;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.logging.log4j.message.Message;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class MyConsoleHandler extends AbstractFilter {
// Put that in the onLoad() or onEnable(): ((Logger) LogManager.getRootLogger()).addFilter(new MyConsoleHandler());
@Override
public Result filter(LogEvent logEvent) {
sendMessage(logEvent.getMessage().getFormat());
return super.filter(logEvent);
}
private void sendMessage(String message) {
for (Player player : Bukkit.getOnlinePlayers())
player.sendMessage("§fConsole output: §a" + message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment