Created
April 10, 2021 16:48
-
-
Save WizardlyBump17/35038b97497dc8e91fcc83bc4667e752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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