SteamWar/BungeeCore
Archiviert
13
2

Add some new punishments after talking with mods #352

Zusammengeführt
Lixfel hat 8 Commits von Punishment++ nach master 2022-05-01 22:20:01 +02:00 zusammengeführt
2 geänderte Dateien mit 21 neuen und 22 gelöschten Zeilen
Nur Änderungen aus Commit 2ef6901f8e werden angezeigt - Alle Commits anzeigen

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()) {
YoyoNow markierte diese Unterhaltung als gelöst
Review

WÜrde hier die Prüfung weglassen und nur die nach der for-Schleife nutzen

WÜrde hier die Prüfung weglassen und nur die nach der for-Schleife nutzen
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;
}
}