Added online indicators for party info

This commit is contained in:
Stijn 2022-05-23 21:55:36 +02:00
parent 29dd5d2d55
commit 1946cd4ab7
2 changed files with 15 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import io.leangen.geantyref.TypeToken;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.yaml.NodeStyle;
@ -290,7 +291,10 @@ public final class Config {
Password: <dark_aqua><password></dark_aqua>
Owner: <owner>
Members: <members>""";
public static Component ONLINE_PREFIX = null;
public static Component OFFLINE_PREFIX = null;
private static void party() {
MiniMessage miniMessage = MiniMessage.miniMessage();
PARTY_FORMAT = getString("party.format", PARTY_FORMAT);
PARTY_SPY = getString("party.spy", PARTY_SPY);
NO_PERMISSION = getString("party.messages.no-permission", NO_PERMISSION);
@ -321,6 +325,8 @@ public final class Config {
DISBANDED_PARTY = getString("party.messages.disbanded-party", DISBANDED_PARTY);
PARTY_INFO = getString("party.messages.party-info", PARTY_INFO);
ALREADY_IN_THIS_PARTY = getString("party.messages.already-in-this-party", ALREADY_IN_THIS_PARTY);
ONLINE_PREFIX = miniMessage.deserialize(getString("party.messages.online-prefix", "<green>■ </green>"));
OFFLINE_PREFIX = miniMessage.deserialize(getString("party.messages.offline-prefix", "<red>■ </red>"));
}
public static String PARTY_HELP_WRAPPER = "<gold>ChatParty help:\n<commands></gold>";

View File

@ -5,16 +5,20 @@ import com.alttd.chat.managers.PartyManager;
import com.alttd.chat.objects.Party;
import com.alttd.chat.objects.PartyUser;
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.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class Info implements SubCommand {
@Override
public String getName() {
return "info";
@ -34,7 +38,11 @@ public class Info implements SubCommand {
List<Component> displayNames = new ArrayList<>();
for (PartyUser partyUser : party.getPartyUsers()) {
displayNames.add(partyUser.getDisplayName());
Optional<Player> optionalPlayer = VelocityChat.getPlugin().getProxy().getPlayer(partyUser.getUuid());
if (optionalPlayer.isPresent() && optionalPlayer.get().isActive())
displayNames.add(Config.ONLINE_PREFIX.append(partyUser.getDisplayName()));
else
displayNames.add(Config.OFFLINE_PREFIX.append(partyUser.getDisplayName()));
}
source.sendMessage(Utility.parseMiniMessage(Config.PARTY_INFO,