SteamWar/BungeeCore
Archiviert
13
2

Rework whois
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-08-31 08:09:12 +02:00
Ursprung a308f9b940
Commit cd044adc55
3 geänderte Dateien mit 44 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.*;
import lombok.Getter;
import net.md_5.bungee.BungeeCord;
@ -78,55 +79,56 @@ public class WhoisCommand extends SWCommand {
}
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, EnumSet<WhoisParameterTypes> parameterTypes) {
SteamwarUser sender = SteamwarUser.get(player.getUniqueId());
Message.send("WHOIS_USERNAME", player, user.getUserName());
Message.send("WHOIS_PERMS", player, user.perms().stream().map(Enum::name).collect(Collectors.joining(", ")));
ChatSender sender = ChatSender.of(player);
Team team = Team.get(user.getTeam());
Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
if (!sender.hasPerm(UserPerm.TEAM)) return;
if (sender.hasPerm(UserPerm.MODERATION)) {
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUUID().toString()), user.getUUID().toString());
Message.send("WHOIS_ID", player, user.getId());
if (user.getDiscordId() != null) {
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
}
sender.system("WHOIS_USERNAME", user.getUserName());
sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
if (!sender.user().hasPerm(UserPerm.TEAM))
return;
if (sender.user().hasPerm(UserPerm.ADMINISTRATION)) {
sender.system("WHOIS_ID", user.getId());
sender.system("WHOIS_UUID", new Message("WHOIS_UUID_HOVER"), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUUID().toString()), user.getUUID().toString());
if (user.getDiscordId() != null)
sender.system("WHOIS_DISCORD_ID", user.getDiscordId());
sender.system("WHOIS_PERMS", user.perms().stream().map(Enum::name).collect(Collectors.joining(", ")));
}
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID());
Timestamp firstJoin = user.getFirstjoin();
if (firstJoin == null) {
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
} else {
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
}
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
if(BungeeCord.getInstance().getPlayer(user.getUUID()) != null) {
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID());
Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName());
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
double onlineTime = user.getOnlinetime();
if(firstJoin == null && target != null) {
firstJoin = Storage.sessions.get(target);
}
if (Utils.playerModMap.containsKey(user.getUUID())) {
Mod.Platform modPlatform = Utils.playerModMap.get(user.getUUID()).get(0).getPlatform();
Message.send("WHOIS_PLATFORM", player, modPlatform.toString());
}
if(firstJoin != null)
sender.system("WHOIS_JOINED_FIRST", firstJoin.toString());
sender.system("WHOIS_HOURS_PLAYED", new DecimalFormat("###.##").format(onlineTime / 3600d));
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
List<Mod> activeMods = Utils.playerModMap.get(user.getUUID());
if(target != null) {
sender.system("WHOIS_CURRENT_PLAYED", new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
sender.system("WHOIS_CURRENT_SERVER", target.getServer().getInfo().getName());
sender.system("WHOIS_CURRENT_PROTOCOL", target.getPendingConnection().getVersion());
if (activeMods != null && !activeMods.isEmpty()) {
Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size());
String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, "));
Message.send("WHOIS_ACTIVE_MOD", player, result);
} else {
Message.send("WHOIS_NO_ACTIVE_MODS", player);
List<Mod> mods = Utils.playerModMap.get(user.getUUID());
if(mods == null)
mods = Collections.emptyList();
sender.system("WHOIS_PLATFORM", mods.isEmpty() ? "Vanilla" : mods.get(0).getPlatform().toString());
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
if (!mods.isEmpty()) {
sender.system("WHOIS_ACTIVE_MODS", mods.size(), mods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")));
} else {
sender.system("WHOIS_NO_ACTIVE_MODS");
}
}
}
Message.send("WHOIS_PUNISHMENTS", player);
sender.system("WHOIS_PUNISHMENTS");
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
Set<Punishment.PunishmentType> found = new HashSet<>();
boolean isPunished = false;
@ -138,11 +140,11 @@ public class WhoisCommand extends SWCommand {
if (!all && !punishment.isCurrent()) {
continue;
}
Message.sendPrefixless("WHOIS_PUNISHMENT", player, SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
sender.prefixless("WHOIS_PUNISHMENT", SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
isPunished = true;
}
if (!isPunished) {
Message.send(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT", player);
sender.system(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT");
}
}

Datei anzeigen

@ -602,13 +602,12 @@ WHOIS_CURRENT_SERVER=§7Current Server§8: §e{0}
WHOIS_CURRENT_PROTOCOL=§7Current Protocol§8: §e{0}
WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2}
WHOIS_TEAM_HOVER=§eShow {0}
WHOIS_PUNISHMENTS=§7Punish:
WHOIS_PUNISHMENTS=§7Punishments:
WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4}
WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet.
WHOIS_ACTIVE_MODS=§7Active Mods ({0}):
WHOIS_ACTIVE_MODS=§7Active Mods ({0}): {1}
WHOIS_NO_ACTIVE_MODS=§7This player has no active mods.
WHOIS_ACTIVE_MOD={0}
WHOIS_PLATFORM=§7Modloader: §e{0}
#VerifyCommand

Datei anzeigen

@ -585,7 +585,7 @@ WHOIS_PUNISHMENTS=§7Strafen:
WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4}
WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
WHOIS_ACTIVE_MODS=§7Aktive Mods ({0}):
WHOIS_ACTIVE_MODS=§7Aktive Mods ({0}): {1}
WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods.
#VerifyCommand