Towny event broadcasting to Discord and masked links #96
7 changed files with 362 additions and 358 deletions
|
@ -7,10 +7,10 @@ import buttondevteam.chat.formatting.TellrawEvent;
|
||||||
import buttondevteam.chat.formatting.TellrawPart;
|
import buttondevteam.chat.formatting.TellrawPart;
|
||||||
import buttondevteam.chat.formatting.TellrawSerializer;
|
import buttondevteam.chat.formatting.TellrawSerializer;
|
||||||
import buttondevteam.chat.listener.PlayerListener;
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
|
import buttondevteam.component.channel.Channel;
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
import buttondevteam.lib.TBMCChatEventBase;
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.Color;
|
import buttondevteam.lib.chat.Color;
|
||||||
import buttondevteam.lib.chat.Priority;
|
import buttondevteam.lib.chat.Priority;
|
||||||
import buttondevteam.lib.chat.TellrawSerializableEnum;
|
import buttondevteam.lib.chat.TellrawSerializableEnum;
|
||||||
|
@ -114,7 +114,7 @@ public class ChatProcessing {
|
||||||
else //Due to the online player map, getPlayer() can be more efficient than getAs()
|
else //Due to the online player map, getPlayer() can be more efficient than getAs()
|
||||||
mp = e.getUser().getAs(ChatPlayer.class); //May be null
|
mp = e.getUser().getAs(ChatPlayer.class); //May be null
|
||||||
|
|
||||||
Color colormode = channel.color;
|
Color colormode = channel.Color().get();
|
||||||
if (mp != null && mp.OtherColorMode != null)
|
if (mp != null && mp.OtherColorMode != null)
|
||||||
colormode = mp.OtherColorMode;
|
colormode = mp.OtherColorMode;
|
||||||
if (message.startsWith(">"))
|
if (message.startsWith(">"))
|
||||||
|
@ -122,7 +122,7 @@ public class ChatProcessing {
|
||||||
// If greentext, ignore channel or player colors
|
// If greentext, ignore channel or player colors
|
||||||
|
|
||||||
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
|
ArrayList<ChatFormatter> formatters = addFormatters(colormode);
|
||||||
if (colormode == channel.color && 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) -> {
|
formatters.add(ChatFormatter.builder().color(colormode).onmatch((match, cf) -> {
|
||||||
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
|
cf.setColor(RainbowPresserColors[rpc.getAndUpdate(i -> ++i < RainbowPresserColors.length ? i : 0)]);
|
||||||
|
@ -233,7 +233,7 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getChannelID(Channel channel, CommandSender sender, String origin) {
|
static String getChannelID(Channel channel, CommandSender sender, String origin) {
|
||||||
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName)
|
return ("[" + (MCORIGIN.equals(origin) ? "" : "§8" + origin.substring(0, 1) + "§r|") + channel.DisplayName().get())
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ 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.component.channel.Channel;
|
||||||
|
import buttondevteam.component.channel.Channel.RecipientTestResult;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.architecture.Component;
|
import buttondevteam.lib.architecture.Component;
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
|
||||||
import buttondevteam.lib.chat.Color;
|
import buttondevteam.lib.chat.Color;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package buttondevteam.chat.commands;
|
package buttondevteam.chat.commands;
|
||||||
|
|
||||||
|
import buttondevteam.component.channel.Channel;
|
||||||
import buttondevteam.lib.TBMCChatEventBase;
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package buttondevteam.chat.commands.ucmds;
|
package buttondevteam.chat.commands.ucmds;
|
||||||
|
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.component.channel.Channel;
|
||||||
import buttondevteam.lib.chat.ChatMessage;
|
import buttondevteam.lib.chat.ChatMessage;
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
import buttondevteam.lib.chat.CommandClass;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
@ -54,7 +54,7 @@ public class HistoryCommand extends UCommandBase {
|
||||||
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
|
for (int i = Math.max(0, arr.length - 10); i < arr.length; i++) {
|
||||||
HistoryEntry e = arr[i];
|
HistoryEntry e = arr[i];
|
||||||
val cm = e.chatMessage;
|
val cm = e.chatMessage;
|
||||||
sender.sendMessage("[" + e.channel.DisplayName + "] " + cm.getSender().getName() + ": " + cm.getMessage());
|
sender.sendMessage("[" + e.channel.DisplayName().get() + "] " + cm.getSender().getName() + ": " + cm.getMessage());
|
||||||
sent.set(true);
|
sent.set(true);
|
||||||
}
|
}
|
||||||
if (!sent.get())
|
if (!sent.get())
|
||||||
|
|
|
@ -2,7 +2,7 @@ package buttondevteam.chat.components;
|
||||||
|
|
||||||
import buttondevteam.chat.ChatProcessing;
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.component.channel.Channel;
|
||||||
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;
|
||||||
|
|
|
@ -4,9 +4,13 @@ import buttondevteam.chat.ChatPlayer;
|
||||||
import buttondevteam.chat.ChatProcessing;
|
import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
||||||
|
import buttondevteam.component.channel.Channel;
|
||||||
|
import buttondevteam.component.channel.ChatChannelRegisterEvent;
|
||||||
|
import buttondevteam.component.channel.ChatRoom;
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.chat.*;
|
import buttondevteam.lib.chat.ChatMessage;
|
||||||
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import buttondevteam.lib.player.ChromaGamerBase;
|
import buttondevteam.lib.player.ChromaGamerBase;
|
||||||
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
||||||
import buttondevteam.lib.player.TBMCPlayer;
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
|
@ -78,7 +82,7 @@ public class PlayerListener implements Listener {
|
||||||
int index = message.indexOf(" ");
|
int index = message.indexOf(" ");
|
||||||
val mp = ChromaGamerBase.getFromSender(sender);
|
val mp = ChromaGamerBase.getFromSender(sender);
|
||||||
String cmd;
|
String cmd;
|
||||||
final BiPredicate<Channel, String> checkchid = (chan, cmd1) -> cmd1.equalsIgnoreCase(chan.ID) || (chan.IDs != null && Arrays.stream(chan.IDs).anyMatch(cmd1::equalsIgnoreCase));
|
final BiPredicate<Channel, String> checkchid = (chan, cmd1) -> cmd1.equalsIgnoreCase(chan.ID) || (Arrays.stream(chan.IDs().get()).anyMatch(cmd1::equalsIgnoreCase));
|
||||||
if (index == -1) { // Only the command is run
|
if (index == -1) { // Only the command is run
|
||||||
if (!(sender instanceof Player || sender instanceof ConsoleCommandSender))
|
if (!(sender instanceof Player || sender instanceof ConsoleCommandSender))
|
||||||
return false;
|
return false;
|
||||||
|
@ -96,7 +100,7 @@ public class PlayerListener implements Listener {
|
||||||
if (channel instanceof ChatRoom)
|
if (channel instanceof ChatRoom)
|
||||||
((ChatRoom) channel).joinRoom(sender);
|
((ChatRoom) channel).joinRoom(sender);
|
||||||
}
|
}
|
||||||
sender.sendMessage("§6You are now talking in: §b" + mp.channel().get().DisplayName);
|
sender.sendMessage("§6You are now talking in: §b" + mp.channel().get().DisplayName().get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +269,7 @@ public class PlayerListener implements Listener {
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
if (e.shouldSendTo(p))
|
if (e.shouldSendTo(p))
|
||||||
p.sendMessage("§c!§r["
|
p.sendMessage("§c!§r["
|
||||||
+ e.getChannel().DisplayName + "] <" + (e.getSender() instanceof Player
|
+ e.getChannel().DisplayName().get() + "] <" + (e.getSender() instanceof Player
|
||||||
? ((Player) e.getSender()).getDisplayName() : e.getSender().getName())
|
? ((Player) e.getSender()).getDisplayName() : e.getSender().getName())
|
||||||
+ "> " + e.getMessage());
|
+ "> " + e.getMessage());
|
||||||
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex);
|
TBMCCoreAPI.SendException("An error occured while processing a chat message!", ex);
|
||||||
|
|
|
@ -7,8 +7,8 @@ import buttondevteam.chat.formatting.TellrawEvent;
|
||||||
import buttondevteam.chat.formatting.TellrawEvent.ClickAction;
|
import buttondevteam.chat.formatting.TellrawEvent.ClickAction;
|
||||||
import buttondevteam.chat.formatting.TellrawEvent.HoverAction;
|
import buttondevteam.chat.formatting.TellrawEvent.HoverAction;
|
||||||
import buttondevteam.chat.formatting.TellrawPart;
|
import buttondevteam.chat.formatting.TellrawPart;
|
||||||
|
import buttondevteam.component.channel.Channel;
|
||||||
import buttondevteam.core.TestPrepare;
|
import buttondevteam.core.TestPrepare;
|
||||||
import buttondevteam.lib.chat.Channel;
|
|
||||||
import buttondevteam.lib.chat.Color;
|
import buttondevteam.lib.chat.Color;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
Loading…
Reference in a new issue