started migrating party to proxy
This commit is contained in:
parent
57a43e9c1c
commit
daf6ab21a5
|
|
@ -209,13 +209,6 @@ public final class Config {
|
|||
GCCOOLDOWN = getInt("commands.globalchat.cooldown", GCCOOLDOWN);
|
||||
}
|
||||
|
||||
public static String PARTY_FORMAT = "<dark_aqua>(<gray><sender></gray> <hover:show_text:on <server>> → Party</hover>) <message>";
|
||||
public static String PARTY_SPY = "<i><gray>PC:</gray><dark_gray> <dark_gray><sendername></dark_gray>: <dark_gray><partyname></dark_gray> <message></dark_gray></i>";
|
||||
private static void party() {
|
||||
PARTY_FORMAT = getString("party.format", PARTY_FORMAT);
|
||||
PARTY_SPY = getString("party.spy", PARTY_SPY);
|
||||
}
|
||||
|
||||
public static String CHATFORMAT = "<white><light_purple><prefixall> <gray><hover:show_text:Click to message <sendername>><click:suggest_command:/msg <sendername> ><sender></hover>: <white><message>";
|
||||
public static String URLFORMAT = "<click:OPEN_URL:<clickurl>><url></click>";
|
||||
private static void Chat() {
|
||||
|
|
@ -252,6 +245,39 @@ public final class Config {
|
|||
|
||||
}
|
||||
|
||||
public static String PARTY_FORMAT = "<dark_aqua>(<gray><sender></gray> <hover:show_text:on <server>> → Party</hover>) <message>";
|
||||
public static String PARTY_SPY = "<i><gray>PC:</gray><dark_gray> <dark_gray><sendername></dark_gray>: <dark_gray><partyname></dark_gray> <message></dark_gray></i>";
|
||||
public static String PARTY_HELP = "";
|
||||
public static String NO_PERMISSION = "<red>You don't have permission to use this command.</red>";
|
||||
public static String NO_CONSOLE = "<red>This command can not be used by console</red>";
|
||||
public static String CREATED_PARTY = "<green>You created a chat party called: " +
|
||||
"'<gold><party_name></gold>' with the password: '<gold><party_password></gold>'</green>";
|
||||
public static String NOT_IN_A_PARTY = "<red>You're not in a chat party.</red>";
|
||||
public static String NOT_YOUR_PARTY = "<red>You don't own this chat party.</red>";
|
||||
public static String NOT_A_PARTY = "<red>This chat party does not exist.</red>";
|
||||
public static String INVALID_PLAYER = "<red>Invalid player.</red>";
|
||||
public static String NOT_ONLINE = "<red><player> must be online to receive an invite.</red>";
|
||||
public static String INVALID_PASSWORD = "<red>Invalid password.</red>";
|
||||
public static String JOINED_PARTY = "<green>You joined <party_name>!</green>";
|
||||
public static String NOTIFY_FINDING_NEW_OWNER = "<dark_aqua>Since you own this chat party a new party owner will be chosen.<dark_aqua>";
|
||||
public static String LEFT_PARTY = "<green>You have left the chat party!</green>";
|
||||
private static void party() {
|
||||
PARTY_FORMAT = getString("party.format", PARTY_FORMAT);
|
||||
PARTY_SPY = getString("party.spy", PARTY_SPY);
|
||||
PARTY_HELP = getString("party.messages.help", PARTY_HELP);
|
||||
NO_PERMISSION = getString("party.messages.no-permission", NO_PERMISSION);
|
||||
NO_CONSOLE = getString("party.messages.no-console", NO_CONSOLE);
|
||||
CREATED_PARTY = getString("party.messages.created-party", CREATED_PARTY);
|
||||
NOT_IN_A_PARTY = getString("party.messages.not-in-a-party", NOT_IN_A_PARTY);
|
||||
NOT_YOUR_PARTY = getString("party.messages.not-your-party", NOT_YOUR_PARTY);
|
||||
NOT_A_PARTY = getString("party.messages.not-a-party", NOT_A_PARTY);
|
||||
INVALID_PLAYER = getString("party.messages.invalid-player", INVALID_PLAYER);
|
||||
NOT_ONLINE = getString("party.messages.not-online", NOT_ONLINE);
|
||||
INVALID_PASSWORD = getString("party.messages.invalid-password", INVALID_PASSWORD);
|
||||
NOTIFY_FINDING_NEW_OWNER = getString("party.messages.notify-finding-new-owner", NOTIFY_FINDING_NEW_OWNER);
|
||||
LEFT_PARTY = getString("party.messages.left-party", LEFT_PARTY);
|
||||
}
|
||||
|
||||
private static void chatChannels() {
|
||||
ConfigurationNode node = getNode("chat-channels");
|
||||
if (node.empty()) {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public class ChatHandler {
|
|||
Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
|
||||
|
||||
Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
||||
sendPartyMessage(player, party.getPartyId(), component);
|
||||
// sendPartyMessage(player, party.getPartyId(), component);
|
||||
|
||||
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
|
||||
for(Player pl : Bukkit.getOnlinePlayers()) {
|
||||
|
|
@ -238,15 +238,6 @@ public class ChatHandler {
|
|||
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
||||
}
|
||||
|
||||
private void sendPartyMessage(Player player, int partyId, Component component) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("party");
|
||||
out.writeUTF(String.valueOf(partyId));
|
||||
out.writeUTF(player.getUniqueId().toString());
|
||||
out.writeUTF(GsonComponentSerializer.gson().serialize(component));
|
||||
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
|
||||
}
|
||||
|
||||
// Start - move these to util
|
||||
|
||||
private boolean isMuted(Player player, String message, String prefix) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
package com.alttd.velocitychat.commands;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.velocitychat.commands.partysubcommands.Create;
|
||||
import com.alttd.velocitychat.commands.partysubcommands.Invite;
|
||||
import com.alttd.velocitychat.commands.partysubcommands.Join;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Party implements SimpleCommand {
|
||||
private final List<SubCommand> subCommands;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public Party() {
|
||||
subCommands = Arrays.asList(new Create(),
|
||||
new Invite(),
|
||||
new Join());
|
||||
miniMessage = MiniMessage.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
String[] args = invocation.arguments();
|
||||
CommandSource source = invocation.source();
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!source.hasPermission("party.use"))
|
||||
source.sendMessage(miniMessage.parse(Config.NO_PERMISSION));
|
||||
else if (source instanceof Player)
|
||||
source.sendMessage(miniMessage.parse(Config.PARTY_HELP));
|
||||
else
|
||||
source.sendMessage(miniMessage.parse(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> subCommand.getName().equalsIgnoreCase(args[0]))
|
||||
.findFirst()
|
||||
.ifPresentOrElse(subCommand -> subCommand.execute(args, source),
|
||||
() -> source.sendMessage(getHelpMessage(source)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
String[] args = invocation.arguments();
|
||||
List<String> suggest = new ArrayList<>();
|
||||
|
||||
if (args.length == 0) {
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission()))
|
||||
.forEach(subCommand -> suggest.add(subCommand.getName()));
|
||||
} else if (args.length <= 1) {
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission()))
|
||||
.filter(subCommand -> subCommand.getName().startsWith(args[0].toLowerCase()))
|
||||
.forEach(subCommand -> suggest.add(subCommand.getName()));
|
||||
} else {
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission()))
|
||||
.filter(subCommand -> subCommand.getName().equalsIgnoreCase(args[0]))
|
||||
.findFirst()
|
||||
.ifPresent(subCommand -> suggest.addAll(subCommand.suggest(args)));
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
return suggest;
|
||||
else
|
||||
return finalizeSuggest(suggest, args[args.length - 1]);
|
||||
}
|
||||
|
||||
public List<String> finalizeSuggest(List<String> possibleValues, String remaining) {
|
||||
List<String> finalValues = new ArrayList<>();
|
||||
|
||||
for (String str : possibleValues) {
|
||||
if (str.toLowerCase().startsWith(remaining)) {
|
||||
finalValues.add(StringArgumentType.escapeIfRequired(str));
|
||||
}
|
||||
}
|
||||
|
||||
return finalValues;
|
||||
}
|
||||
|
||||
private Component getHelpMessage(CommandSource source) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
subCommands.stream()
|
||||
.filter(subCommand -> source.hasPermission(subCommand.getPermission()))
|
||||
.forEach(subCommand -> stringBuilder.append(subCommand.getHelpMessage()).append("\n"));
|
||||
if (stringBuilder.length() != 0)
|
||||
stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), "");
|
||||
|
||||
return miniMessage.parse(Config.PARTY_HELP, Template.of("commands", stringBuilder.toString()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.alttd.velocitychat.commands;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SubCommand {
|
||||
|
||||
String getName();
|
||||
|
||||
default String getPermission() {
|
||||
return "party." + getName();
|
||||
}
|
||||
|
||||
void execute(String[] args, CommandSource source);
|
||||
|
||||
List<String> suggest(String[] args);
|
||||
|
||||
String getHelpMessage();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.alttd.velocitychat.commands.partysubcommands;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.alttd.velocitychat.commands.SubCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Create implements SubCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "create";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
if (args.length < 3 || !args[1].matches("[\\w]{3,16}") || !args[2].matches("[\\w]{3,16}")) {
|
||||
source.sendMessage(Utility.parseMiniMessage(getHelpMessage()));
|
||||
return;
|
||||
}
|
||||
if (PartyManager.getParty(args[1]) != null) {
|
||||
source.sendMessage(Utility.parseMiniMessage("<red>A chat party with this name already exists.</red>"));
|
||||
return;
|
||||
}
|
||||
Party party = Queries.addParty(player.getUniqueId(), args[1], args[2]);
|
||||
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
|
||||
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
||||
PartyManager.addParty(party);
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.CREATED_PARTY,
|
||||
List.of(Template.template("party_name", party.getPartyName()),
|
||||
Template.template("party_password", party.getPartyPassword()))));
|
||||
// update(player, party.getPartyId());
|
||||
//TODO put party in active party list
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.alttd.velocitychat.commands.partysubcommands;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.alttd.velocitychat.VelocityChat;
|
||||
import com.alttd.velocitychat.commands.SubCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Invite implements SubCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "invite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
source.sendMessage(Utility.parseMiniMessage(getHelpMessage()));
|
||||
return;
|
||||
}
|
||||
Party party = PartyManager.getParty(player.getUniqueId());
|
||||
if (party == null) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_IN_A_PARTY));
|
||||
return;
|
||||
}
|
||||
if (!party.getOwnerUuid().equals(player.getUniqueId())) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_YOUR_PARTY));
|
||||
return;
|
||||
}
|
||||
Optional<Player> optional = VelocityChat.getPlugin().getProxy().getPlayer(args[1]);
|
||||
if (optional.isEmpty()) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.INVALID_PLAYER));
|
||||
return;
|
||||
}
|
||||
Player target = optional.get();
|
||||
|
||||
if (!target.isActive()) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_ONLINE, List.of(
|
||||
Template.template("player", target.getUsername())
|
||||
)));
|
||||
return;
|
||||
}
|
||||
|
||||
target.sendMessage(Utility.parseMiniMessage("<click:run_command:'/chatparty join " + party.getPartyName() + " " + party.getPartyPassword() +
|
||||
"'><dark_aqua>You received an invite to join " + party.getPartyName() + " click this message to accept.</dark_aqua></click>"));
|
||||
source.sendMessage(Utility.parseMiniMessage("<green>You send a chat party invite to <player>!</green>", List.of(
|
||||
Template.template("player", target.getUsername())
|
||||
)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.alttd.velocitychat.commands.partysubcommands;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.alttd.velocitychat.commands.SubCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Join implements SubCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "join";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
if (args.length < 3 || !args[1].matches("[\\w]{3,16}") || !args[2].matches("[\\w]{3,16}")) {
|
||||
source.sendMessage(Utility.parseMiniMessage(getHelpMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = PartyManager.getParty(args[1]);
|
||||
if (party == null) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_A_PARTY));
|
||||
return;
|
||||
}
|
||||
if (!party.getPartyPassword().equals(args[2])) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.INVALID_PASSWORD));
|
||||
return;
|
||||
}
|
||||
|
||||
// party.addUser(ChatUserManager.getChatUser(player.getUniqueId())); //Removed until we can get nicknames to translate to colors correctly
|
||||
party.addUser(ChatUserManager.getChatUser(player.getUniqueId()), player.getUsername());
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.JOINED_PARTY, List.of(
|
||||
Template.template("party_name", party.getPartyName()))));
|
||||
// update(player, party.getPartyId()); TODO update party
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.alttd.velocitychat.commands.partysubcommands;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import com.alttd.velocitychat.VelocityChat;
|
||||
import com.alttd.velocitychat.commands.SubCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Leave implements SubCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "leave";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
Party party = PartyManager.getParty(player.getUniqueId());
|
||||
if (party == null) {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOT_IN_A_PARTY));
|
||||
return;
|
||||
}
|
||||
Optional<ServerConnection> currentServer = player.getCurrentServer();
|
||||
if (currentServer.isEmpty())
|
||||
return;
|
||||
|
||||
party.removeUser(player.getUniqueId());
|
||||
if (party.getOwnerUuid().equals(player.getUniqueId())) {
|
||||
if (party.getPartyUsers().size() > 0) {
|
||||
UUID uuid = party.newOwner();
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.NOTIFY_FINDING_NEW_OWNER));
|
||||
VelocityChat.getPlugin().getChatHandler().partyMessage(party, player, "<dark_aqua>" +
|
||||
player.getUsername() +
|
||||
" left the chat party, the new party owner is " + party.getPartyUser(uuid).getPlayerName(),
|
||||
currentServer.get());
|
||||
} else {
|
||||
party.delete();
|
||||
}
|
||||
} else {
|
||||
source.sendMessage(Utility.parseMiniMessage(Config.LEFT_PARTY));
|
||||
}
|
||||
// update(player, party.getPartyId()); TODO update party
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.alttd.chat.config.Config;
|
|||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.Mail;
|
||||
import com.alttd.chat.objects.Party;
|
||||
|
|
@ -16,6 +17,7 @@ import com.velocitypowered.api.command.CommandSource;
|
|||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
|
|
@ -83,6 +85,50 @@ public class ChatHandler {
|
|||
// player2.sendMessage(receiverMessage);
|
||||
}
|
||||
|
||||
public void partyMessage(Party party, Player player, String message, ServerConnection serverConnection) {
|
||||
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
|
||||
Component senderName = user.getDisplayName();
|
||||
|
||||
String updatedMessage = RegexManager.replaceText(player.getUsername(), player.getUniqueId(), message);
|
||||
if(updatedMessage == null) {
|
||||
// GalaxyUtility.sendBlockedNotification("Party Language", player, message, "");
|
||||
return; // the message was blocked
|
||||
}
|
||||
|
||||
if(!player.hasPermission("chat.format")) {
|
||||
updatedMessage = Utility.stripTokens(updatedMessage);
|
||||
}
|
||||
|
||||
if(updatedMessage.contains("[i]")) updatedMessage = updatedMessage.replace("[i]", "<[i]>");
|
||||
|
||||
updatedMessage = Utility.formatText(updatedMessage);
|
||||
|
||||
List<Template> templates = new ArrayList<>(List.of(
|
||||
Template.template("sender", senderName),
|
||||
Template.template("sendername", senderName),
|
||||
Template.template("partyname", party.getPartyName()),
|
||||
Template.template("message", updatedMessage),
|
||||
Template.template("server", serverConnection.getServer().getServerInfo().getName()),
|
||||
Template.template("[i]", "item")
|
||||
));
|
||||
|
||||
Component partyMessage = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
|
||||
VelocityChat.getPlugin().getProxy().getAllPlayers().stream()
|
||||
.filter(pl -> {
|
||||
UUID uuid = pl.getUniqueId();
|
||||
return party.getPartyUsers().stream().anyMatch(pu -> pu.getUuid().equals(uuid));
|
||||
}).forEach(pl -> {
|
||||
pl.sendMessage(partyMessage);
|
||||
});
|
||||
|
||||
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
|
||||
for(Player pl : serverConnection.getServer().getPlayersConnected()) {
|
||||
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
|
||||
pl.sendMessage(spyMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void globalAdminChat(String message) {
|
||||
Component component = GsonComponentSerializer.gson().deserialize(message);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user