Towny logger works

TBMCPlugins/DiscordPlugin#81
This commit is contained in:
Norbi Peti 2019-01-09 18:57:21 +01:00
parent be29caa904
commit bfe7d48760
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 16 additions and 6 deletions

View file

@ -87,7 +87,7 @@ public class ChatProcessing {
.registerTypeAdapter(Boolean.class, new TellrawSerializer.TwBool())
.registerTypeAdapter(boolean.class, new TellrawSerializer.TwBool()).disableHtmlEscaping().create();
private static final String[] testPlayers = {"Koiiev", "iie", "Alisolarflare", "NorbiPeti", "Arsen_Derby_FTW", "carrot_lynx"};
static final String MCORIGIN = "Minecraft"; //Shouldn't change, like ever - TBMCPlayer.getFolderForType(TBMCPlayer.class) capitalized
public static final String MCORIGIN = "Minecraft"; //Shouldn't change, like ever - TBMCPlayer.getFolderForType(TBMCPlayer.class) capitalized
private ChatProcessing() {
}

View file

@ -2,10 +2,13 @@ package buttondevteam.chat;
import buttondevteam.chat.commands.YeehawCommand;
import buttondevteam.chat.commands.ucmds.TownColorCommand;
import buttondevteam.chat.components.TownColorComponent;
import buttondevteam.chat.components.TownyComponent;
import buttondevteam.chat.listener.PlayerJoinLeaveListener;
import buttondevteam.chat.listener.PlayerListener;
import buttondevteam.chat.listener.TownyListener;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.Channel.RecipientTestResult;
import buttondevteam.lib.chat.Color;
@ -115,6 +118,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
new Thread(this::FlairGetterThreadMethod).start();
new Thread(new AnnouncerThread()).start();
Component.registerComponent(this, new TownyComponent());
Component.registerComponent(this, new TownColorComponent());
}
/**

View file

@ -1,5 +1,6 @@
package buttondevteam.chat.components;
import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.PluginMain;
import buttondevteam.lib.chat.Channel;
import buttondevteam.lib.chat.TBMCChatAPI;
@ -11,7 +12,7 @@ import java.util.logging.LogRecord;
import java.util.regex.Pattern;
public class TownyAnnouncer {
private static final Pattern LOG_TYPE_PATTERN = Pattern.compile("\\[(\\w+ (?:Msg|Message))] (\\w+):");
private static final Pattern LOG_TYPE_PATTERN = Pattern.compile("\\[(\\w+) (?:Msg|Message)](?: (\\w+):)?");
private static final Handler HANDLER = new Handler() {
@Override
public void publish(LogRecord logRecord) {
@ -23,14 +24,17 @@ public class TownyAnnouncer {
case "Town":
TBMCChatAPI.SendSystemMessage(PluginMain.TownChat,
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, false), groupID),
logRecord.getMessage()); //TODO: This will also send it in Minecraft
logRecord.getMessage(), ChatProcessing.MCORIGIN);
break;
case "Nation":
TBMCChatAPI.SendSystemMessage(PluginMain.NationChat,
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, true), groupID),
logRecord.getMessage()); //TODO: This will also send it in Minecraft
logRecord.getMessage(), ChatProcessing.MCORIGIN);
break;
case "Global": //TODO
case "Global":
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat,
Channel.RecipientTestResult.ALL,
logRecord.getMessage(), ChatProcessing.MCORIGIN);
break;
}
}

View file

@ -2,7 +2,7 @@ package buttondevteam.chat.components;
import buttondevteam.lib.architecture.Component;
public class TownyComponent extends Component { //TODO: Register component
public class TownyComponent extends Component {
@Override
protected void enable() {
TownyAnnouncer.setup();