Archiviert
1
0

Update WhoisCommand

Add mutlie note punishments
Dieser Commit ist enthalten in:
yoyosource 2022-04-25 11:09:08 +02:00
Ursprung f52444f6e5
Commit 2ef6901f8e
2 geänderte Dateien mit 21 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -29,7 +29,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class WhoisCommand extends BasicCommand {
public WhoisCommand(){
@ -94,28 +96,22 @@ public class WhoisCommand extends BasicCommand {
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());
Message.send("WHOIS_PUNISHMENTS", player);
if(all) {
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
if(punishmentList.isEmpty()) {
Message.send("WHOIS_NO_ALL_PUNISHMENT", player);
return;
}
for (Punishment punishment : punishmentList) {
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());
}
} else {
boolean isPunished = false;
for (Punishment.PunishmentType punishmentType : Punishment.PunishmentType.values()) {
if(!user.isPunished(punishmentType)) {
continue;
}
Punishment punishment = user.getPunishment(punishmentType);
isPunished = true;
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());
}
if(!isPunished) {
Message.send("WHOIS_NO_PUNISHMENT", player);
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
if (punishmentList.isEmpty()) {
Message.send(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT", player);
return;
}
Set<Punishment.PunishmentType> found = new HashSet<>();
boolean isPunished = false;
for (Punishment punishment : punishmentList) {
if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) {
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());
isPunished = true;
}
if (!all && !isPunished) {
Message.send("WHOIS_NO_PUNISHMENT", player);
}
}
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.sql;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -133,6 +134,7 @@ public class Punishment {
}
@AllArgsConstructor
@RequiredArgsConstructor
@Getter
public enum PunishmentType {
Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
@ -143,7 +145,7 @@ public class Punishment {
NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"),
NoFightServer(false, "NOFIGHTSERVER_TEAM", "NOFIGHTSERVER_PERMA", "NOFIGHTSERVER_UNTIL", "UNNOFIGHTSERVER_ERROR", "UNNOFIGHTSERVER"),
NoTeamServer(true, "NOTEAMSERVER_TEAM", "NOTEAMSERVER_PERMA", "NOTEAMSERVER_UNTIL", "UNNOTEAMSERVER_ERROR", "UNNOTEAMSERVER"),
Note(false, "NOTE_TEAM", null, null, null, null),
Note(false, "NOTE_TEAM", null, null, null, null, true),
;
private final boolean needsAdmin;
@ -152,5 +154,6 @@ public class Punishment {
private final String playerMessageUntil;
private final String usageNotPunished;
private final String unpunishmentMessage;
private boolean multi = false;
}
}