-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Tuisku-L/feature/ServerConsole-WS
feat: 实时推送服务器输出
- Loading branch information
Showing
7 changed files
with
85 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
24 changes: 24 additions & 0 deletions
24
src/tech/v2c/minecraft/plugins/jsonApi/EventNotify/Console/ServerConsoleEvent.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tech.v2c.minecraft.plugins.jsonApi.EventNotify.Console; | ||
|
||
import org.apache.logging.log4j.core.LogEvent; | ||
import org.apache.logging.log4j.core.appender.AbstractAppender; | ||
import tech.v2c.minecraft.plugins.jsonApi.EventNotify.global.JsonApiWebSocketServer; | ||
import tech.v2c.minecraft.plugins.jsonApi.tools.results.JsonResult; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
|
||
public class ServerConsoleEvent extends AbstractAppender { | ||
public ServerConsoleEvent() { | ||
super("JSONAPI", null, null); | ||
} | ||
|
||
@Override | ||
public void append(LogEvent logEvent) { | ||
HashMap<Object, Object> result = new HashMap<Object, Object>(); | ||
result.put("type", "ServerConsoleEvent"); | ||
result.put("message", "[" + new Date().toString() + "] " + "[" + logEvent.getLevel().name() + "] " + logEvent.getMessage().getFormattedMessage()); | ||
|
||
JsonApiWebSocketServer.SendMsg(new JsonResult(result)); | ||
} | ||
} |
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
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
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