Renamed partycommand and made party chat work from galaxy to proxy

This commit is contained in:
2022-01-30 19:31:29 +01:00
parent 4f4f48e847
commit 2acebc6c16
14 changed files with 150 additions and 118 deletions
@@ -50,8 +50,8 @@ public class ChatPlugin extends JavaPlugin {
registerCommand("unignore", new Unignore());
registerCommand("muteserver", new MuteServer());
registerCommand("spy", new Spy());
registerCommand("chatparty", new ChatParty());
registerCommand("pc", new PartyChat());
// registerCommand("chatparty", new ChatParty());
registerCommand("p", new PartyChat());
for (Channel channel : Channel.getChannels()) {
if (!(channel instanceof CustomChannel customChannel)) continue;
this.getServer().getCommandMap().register(channel.getChannelName().toLowerCase(), new ChatChannel(customChannel));
@@ -115,9 +115,9 @@ public class ChatParty implements CommandExecutor, TabCompleter {
if (party.getPartyUsers().size() > 0) {
UUID uuid = party.setNewOwner();
sender.sendMessage(Utility.parseMiniMessage("<dark_aqua>Since you own this chat party a new party owner will be chosen.<dark_aqua>"));
ChatPlugin.getInstance().getChatHandler().partyMessage(party, player, "<dark_aqua>" +
player.getName() +
" left the chat party, the new party owner is " + party.getPartyUser(uuid).getPlayerName());
// ChatPlugin.getInstance().getChatHandler().partyMessage(party, player, "<dark_aqua>" +
// player.getName() +
// " left the chat party, the new party owner is " + party.getPartyUser(uuid).getPlayerName());
} else {
party.delete();
}
@@ -20,11 +20,6 @@ public class PartyChat implements CommandExecutor {
if(!(sender instanceof Player player)) { // must be a player
return true;
}
Party party = PartyManager.getParty(player.getUniqueId());
if (party == null) {
sender.sendMessage(Utility.parseMiniMessage("<red>You are not in a party. For more info do <gold>/party</gold>.</red>"));
return true;
}
if(args.length == 0) {
// TODO: 08/08/2021 lock into party chat
@@ -36,7 +31,7 @@ public class PartyChat implements CommandExecutor {
new BukkitRunnable() {
@Override
public void run() {
ChatPlugin.getInstance().getChatHandler().partyMessage(party, player, message);
ChatPlugin.getInstance().getChatHandler().partyMessage(player, message); //TODO send over proxy
}
}.runTaskAsynchronously(ChatPlugin.getInstance());
@@ -164,43 +164,53 @@ public class ChatHandler {
}
}
public void partyMessage(Party party, Player player, String message) {
if (isMuted(player, message, "[" + party.getPartyName() + " Muted] ")) return;
public void partyMessage(Player player, String message) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("party");
out.writeUTF(player.getUniqueId().toString());
out.writeUTF(message);
out.writeUTF(GsonComponentSerializer.gson().serialize(
itemComponent(player.getInventory().getItemInMainHand())
));
player.sendPluginMessage(plugin, Config.MESSAGECHANNEL, out.toByteArray());
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
Component senderName = user.getDisplayName();
String updatedMessage = RegexManager.replaceText(player.getName(), 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", Bukkit.getServerName()),
Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
// sendPartyMessage(player, party.getPartyId(), component);
Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
for(Player pl : Bukkit.getOnlinePlayers()) {
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
pl.sendMessage(spyMessage);
}
}
// if (isMuted(player, message, "[" + party.getPartyName() + " Muted] ")) return;
//
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
// Component senderName = user.getDisplayName();
//
// String updatedMessage = RegexManager.replaceText(player.getName(), 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", Bukkit.getServerName()),
// Template.template("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
//
// Component component = Utility.parseMiniMessage(Config.PARTY_FORMAT, templates);
//// sendPartyMessage(player, party.getPartyId(), component);
//
// Component spyMessage = Utility.parseMiniMessage(Config.PARTY_SPY, templates);
// for(Player pl : Bukkit.getOnlinePlayers()) {
// if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsersUuid().contains(pl.getUniqueId())) {
// pl.sendMessage(spyMessage);
// }
// }
}
private void sendChatChannelMessage(CustomChannel chatChannel, UUID uuid, Component component) {
+2 -4
View File
@@ -27,7 +27,5 @@ commands:
permission: command.chat.mute-server
spy:
permission: command.chat.togglespy
chatparty:
permission: command.chat.chatparty
pc:
permission: command.chat.pc
p:
permission: command.chat.p