#k, 1 min
1 messages · Page 1 of 1 (latest)
make a handler like:
public class LogTransferer extends Handler{
//stuff goes here
}
(Handler is java.util.logging.Handler)
in onEnable() get the logger from the server using Server#getLogger()
call addHandler() on is and pass it in a new instance of the LogTransferer.
in the LogTransferer class override publish(LogRecord record)
in this method you would do whatever you want to do to transfer the log messages, you could do pretty much whatever you want.
so, you could make your plugin a discord bot and post the log in a discord channel, or you could send it to some url, or pass it through a socket, or whatever. up to you.
that last part about sending it to an url and etc., havent actually done any of that but ill do some reading thats a great idea, by any chance, if you know, is it difficult to accomplish said things?
it's been a while since i did http post requests via java, but i don't remember it being too difficult
as for setting up the handler, itself it's pretty simple, i pretty much gave all the steps needed in that first message. one of my plugins uses the discord bot approach and it works well.
does the discord bot run while the server is running together with the plugin or..?
ya, i used a library called JDA, in my onEnable i just initialize a JDA object and then the plugin is a discord bot and a spigot plugin at the same time
going the http route is simpler imo, but i don't host a webserver for my minecraft server anymore, decided to switch everything over to a discord server
lol and i wanted to transfer the info through nms and nbt tags uhhh we are not going to talk about that, though the discord approach probably gonna try that
also, if you decide to go with the discord bot route, you will need to deal with discord's rate limiting, JDA handles keeping track of your rates for you, so discord won't flag your bot as spamming or anything... but sometimes the logging to the discord channel will be slowed down by the rate limiting