Towny event broadcasting to Discord and masked links #96
4 changed files with 16 additions and 6 deletions
|
@ -87,7 +87,7 @@ public class ChatProcessing {
|
||||||
.registerTypeAdapter(Boolean.class, new TellrawSerializer.TwBool())
|
.registerTypeAdapter(Boolean.class, new TellrawSerializer.TwBool())
|
||||||
.registerTypeAdapter(boolean.class, new TellrawSerializer.TwBool()).disableHtmlEscaping().create();
|
.registerTypeAdapter(boolean.class, new TellrawSerializer.TwBool()).disableHtmlEscaping().create();
|
||||||
private static final String[] testPlayers = {"Koiiev", "iie", "Alisolarflare", "NorbiPeti", "Arsen_Derby_FTW", "carrot_lynx"};
|
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() {
|
private ChatProcessing() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,13 @@ package buttondevteam.chat;
|
||||||
|
|
||||||
import buttondevteam.chat.commands.YeehawCommand;
|
import buttondevteam.chat.commands.YeehawCommand;
|
||||||
import buttondevteam.chat.commands.ucmds.TownColorCommand;
|
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.PlayerJoinLeaveListener;
|
||||||
import buttondevteam.chat.listener.PlayerListener;
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
import buttondevteam.chat.listener.TownyListener;
|
import buttondevteam.chat.listener.TownyListener;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import buttondevteam.lib.architecture.Component;
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
||||||
import buttondevteam.lib.chat.Color;
|
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(this::FlairGetterThreadMethod).start();
|
||||||
new Thread(new AnnouncerThread()).start();
|
new Thread(new AnnouncerThread()).start();
|
||||||
|
|
||||||
|
Component.registerComponent(this, new TownyComponent());
|
||||||
|
Component.registerComponent(this, new TownColorComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package buttondevteam.chat.components;
|
package buttondevteam.chat.components;
|
||||||
|
|
||||||
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
|
@ -11,7 +12,7 @@ import java.util.logging.LogRecord;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class TownyAnnouncer {
|
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() {
|
private static final Handler HANDLER = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void publish(LogRecord logRecord) {
|
public void publish(LogRecord logRecord) {
|
||||||
|
@ -23,14 +24,17 @@ public class TownyAnnouncer {
|
||||||
case "Town":
|
case "Town":
|
||||||
TBMCChatAPI.SendSystemMessage(PluginMain.TownChat,
|
TBMCChatAPI.SendSystemMessage(PluginMain.TownChat,
|
||||||
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, false), groupID),
|
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, false), groupID),
|
||||||
logRecord.getMessage()); //TODO: This will also send it in Minecraft
|
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
case "Nation":
|
case "Nation":
|
||||||
TBMCChatAPI.SendSystemMessage(PluginMain.NationChat,
|
TBMCChatAPI.SendSystemMessage(PluginMain.NationChat,
|
||||||
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, true), groupID),
|
new Channel.RecipientTestResult(PluginMain.getTownNationIndex(groupID, true), groupID),
|
||||||
logRecord.getMessage()); //TODO: This will also send it in Minecraft
|
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
case "Global": //TODO
|
case "Global":
|
||||||
|
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat,
|
||||||
|
Channel.RecipientTestResult.ALL,
|
||||||
|
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package buttondevteam.chat.components;
|
||||||
|
|
||||||
import buttondevteam.lib.architecture.Component;
|
import buttondevteam.lib.architecture.Component;
|
||||||
|
|
||||||
public class TownyComponent extends Component { //TODO: Register component
|
public class TownyComponent extends Component {
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
TownyAnnouncer.setup();
|
TownyAnnouncer.setup();
|
||||||
|
|
Loading…
Reference in a new issue