More components, broadcasts #98
4 changed files with 20 additions and 10 deletions
|
@ -52,7 +52,8 @@ public class ChatProcessing {
|
||||||
private static final Pattern SPOILER_PATTERN = Pattern.compile("\\|\\|");
|
private static final Pattern SPOILER_PATTERN = Pattern.compile("\\|\\|");
|
||||||
private static final Color[] RainbowPresserColors = new Color[]{Color.Red, Color.Gold, Color.Yellow, Color.Green,
|
private static final Color[] RainbowPresserColors = new Color[]{Color.Red, Color.Gold, Color.Yellow, Color.Green,
|
||||||
Color.Blue, Color.DarkPurple};
|
Color.Blue, Color.DarkPurple};
|
||||||
private static boolean pingedconsole = false;
|
private static final Pattern WORD_PATTERN = Pattern.compile("\\S+");
|
||||||
|
private static boolean pingedconsole = false;
|
||||||
|
|
||||||
public static final ChatFormatter ESCAPE_FORMATTER = ChatFormatter.builder().regex(ESCAPE_PATTERN).build();
|
public static final ChatFormatter ESCAPE_FORMATTER = ChatFormatter.builder().regex(ESCAPE_PATTERN).build();
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ public class ChatProcessing {
|
||||||
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
|
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
|
||||||
if (colormode == channel.Color().get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
|
if (colormode == channel.Color().get() && mp != null && mp.RainbowPresserColorMode) { // Only overwrite channel color
|
||||||
final AtomicInteger rpc = new AtomicInteger(0);
|
final AtomicInteger rpc = new AtomicInteger(0);
|
||||||
formatters.add(ChatFormatter.builder().color(colormode).onmatch((match, cf, s) -> {
|
formatters.add(ChatFormatter.builder().regex(WORD_PATTERN).color(colormode).onmatch((match, cf, s) -> {
|
||||||
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
|
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
|
||||||
return match;
|
return match;
|
||||||
}).build());
|
}).build());
|
||||||
|
|
|
@ -3,8 +3,9 @@ package buttondevteam.chat.components.fun;
|
||||||
import buttondevteam.core.component.restart.ScheduledRestartCommand;
|
import buttondevteam.core.component.restart.ScheduledRestartCommand;
|
||||||
import buttondevteam.lib.ScheduledServerRestartEvent;
|
import buttondevteam.lib.ScheduledServerRestartEvent;
|
||||||
import buttondevteam.lib.ThorpeUtils;
|
import buttondevteam.lib.ThorpeUtils;
|
||||||
import buttondevteam.lib.chat.Command2MC;
|
import buttondevteam.lib.chat.Command2;
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
|
import buttondevteam.lib.chat.ICommand2MC;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -13,12 +14,12 @@ import org.bukkit.event.Listener;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@CommandClass
|
@CommandClass
|
||||||
public class PressCommand extends Command2MC implements Listener {
|
public class PressCommand extends ICommand2MC implements Listener {
|
||||||
private HashSet<CommandSender> pressers; //Will be cleared with this class on shutdown/disable
|
private HashSet<CommandSender> pressers; //Will be cleared with this class on shutdown/disable
|
||||||
private ScheduledRestartCommand command;
|
private ScheduledRestartCommand command;
|
||||||
private int startTicks;
|
private int startTicks;
|
||||||
|
|
||||||
@Subcommand
|
@Command2.Subcommand
|
||||||
public void def(CommandSender sender) {
|
public void def(CommandSender sender) {
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
sender.sendMessage("§cThe timer isn't ticking... yet.");
|
sender.sendMessage("§cThe timer isn't ticking... yet.");
|
||||||
|
|
|
@ -12,6 +12,7 @@ import buttondevteam.lib.architecture.ConfigData;
|
||||||
import buttondevteam.lib.chat.Color;
|
import buttondevteam.lib.chat.Color;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import lombok.experimental.var;
|
import lombok.experimental.var;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -79,9 +80,10 @@ public class TownColorComponent extends Component {
|
||||||
return;
|
return;
|
||||||
for (val entry : TownColors.entrySet()) {
|
for (val entry : TownColors.entrySet()) {
|
||||||
try {
|
try {
|
||||||
val nation = TownyComponent.TU.getTownsMap().get(entry.getKey()).getNation();
|
val town = TownyComponent.TU.getTownsMap().get(entry.getKey());
|
||||||
|
Nation nation;
|
||||||
Color nc;
|
Color nc;
|
||||||
if (nation == null || (nc = NationColor.get(nation.getName().toLowerCase())) == null)
|
if (!town.hasNation() || (nation = town.getNation()) == null || (nc = NationColor.get(nation.getName().toLowerCase())) == null)
|
||||||
nc = Color.White;
|
nc = Color.White;
|
||||||
setTownColor(dtp, buttondevteam.chat.components.towncolors.admin.TownColorCommand.getTownNameCased(entry.getKey()), entry.getValue(), nc);
|
setTownColor(dtp, buttondevteam.chat.components.towncolors.admin.TownColorCommand.getTownNameCased(entry.getKey()), entry.getValue(), nc);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package buttondevteam.chat.components.towny;
|
||||||
import buttondevteam.chat.ChatProcessing;
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
|
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import com.palmergames.bukkit.towny.TownyLogger;
|
import com.palmergames.bukkit.towny.TownyLogger;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
@ -24,17 +25,17 @@ public class TownyAnnouncer {
|
||||||
case "Town":
|
case "Town":
|
||||||
TBMCChatAPI.SendSystemMessage(PluginMain.TownChat,
|
TBMCChatAPI.SendSystemMessage(PluginMain.TownChat,
|
||||||
new Channel.RecipientTestResult(TownyComponent.getTownNationIndex(groupID, false), groupID),
|
new Channel.RecipientTestResult(TownyComponent.getTownNationIndex(groupID, false), groupID),
|
||||||
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
logRecord.getMessage(), target, ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
case "Nation":
|
case "Nation":
|
||||||
TBMCChatAPI.SendSystemMessage(PluginMain.NationChat,
|
TBMCChatAPI.SendSystemMessage(PluginMain.NationChat,
|
||||||
new Channel.RecipientTestResult(TownyComponent.getTownNationIndex(groupID, true), groupID),
|
new Channel.RecipientTestResult(TownyComponent.getTownNationIndex(groupID, true), groupID),
|
||||||
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
logRecord.getMessage(), target, ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
case "Global":
|
case "Global":
|
||||||
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat,
|
TBMCChatAPI.SendSystemMessage(Channel.GlobalChat,
|
||||||
Channel.RecipientTestResult.ALL,
|
Channel.RecipientTestResult.ALL,
|
||||||
logRecord.getMessage(), ChatProcessing.MCORIGIN);
|
logRecord.getMessage(), target, ChatProcessing.MCORIGIN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,11 +51,16 @@ public class TownyAnnouncer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static TBMCSystemChatEvent.BroadcastTarget target;
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
|
target = TBMCSystemChatEvent.BroadcastTarget.add("towny");
|
||||||
TownyLogger.log.addHandler(HANDLER);
|
TownyLogger.log.addHandler(HANDLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setdown() {
|
public static void setdown() {
|
||||||
|
TBMCSystemChatEvent.BroadcastTarget.remove(target);
|
||||||
|
target = null;
|
||||||
TownyLogger.log.removeHandler(HANDLER);
|
TownyLogger.log.removeHandler(HANDLER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue