Added party spy

This commit is contained in:
2021-08-08 18:27:30 +02:00
parent 18c3c4c6f4
commit c701621e42
3 changed files with 17 additions and 4 deletions
@@ -24,10 +24,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
public class ChatParty implements CommandExecutor, TabCompleter {
@@ -152,6 +149,11 @@ public class ChatParty implements CommandExecutor, TabCompleter {
}
party.removeUser(ChatUserManager.getChatUser(offlinePlayerIfCached.getUniqueId()));
if (offlinePlayerIfCached.getUniqueId().equals(party.getOwnerUuid())) {
sender.sendMessage(MiniMessage.get().parse("<red>You can't remove yourself, please leave instead.</red>"));
return;
}
if (offlinePlayerIfCached.isOnline()) {
Objects.requireNonNull(offlinePlayerIfCached.getPlayer())
.sendMessage(MiniMessage.get().parse("<red>You were removed from the '" + party.getPartyName() + "' chat party."));
@@ -181,12 +181,21 @@ public class ChatHandler {
List<Template> templates = new ArrayList<>(List.of(
Template.of("sender", senderName),
Template.of("sendername", senderName),
Template.of("partyname", party.getPartyName()),
Template.of("message", updatedMessage),
Template.of("server", Bukkit.getServerName()),
Template.of("[i]", itemComponent(player.getInventory().getItemInMainHand()))));
Component component = miniMessage.parse(Config.PARTY_FORMAT, templates);
sendPartyMessage(player, party.getPartyId(), component);
Component spyMessage = miniMessage.parse(Config.PARTY_SPY, templates);
for(Player pl : Bukkit.getOnlinePlayers()) {
if(pl.hasPermission(Config.SPYPERMISSION) && !party.getPartyUsers().containsKey(pl.getUniqueId())) { // todo add a toggle for social spy
pl.sendMessage(spyMessage);
}
}
}
private void sendChatChannelMessage(CustomChannel chatChannel, UUID uuid, Component component) {