SteamWar/BungeeCore
Archiviert
13
2
Dieser Commit ist enthalten in:
Chaoscaot 2021-01-22 10:41:57 +01:00
Ursprung cac7b66208
Commit bef39c7cc2
7 geänderte Dateien mit 30 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -57,7 +57,7 @@ public class BanCommand extends BasicCommand {
boolean isPerma = args[1].equalsIgnoreCase("perma"); boolean isPerma = args[1].equalsIgnoreCase("perma");
String msg = banReason.toString(); String msg = banReason.toString();
target.ban(banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma); target.ban(banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma);
Message.team("BAN_TEAM_BANNED", target.getUserName(), sender.getName(), new Message((isPerma?"BAN_PERMA":"BAN_UNTIL"), banTime), msg); Message.team("BAN_TEAM_BANNED", new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((isPerma?"BAN_PERMA":"BAN_UNTIL"), banTime), msg);
} }
public static Timestamp parseTime(CommandSender sender, String arg){ public static Timestamp parseTime(CommandSender sender, String arg){

Datei anzeigen

@ -52,6 +52,6 @@ public class MuteCommand extends BasicCommand {
} }
String msg = muteReason.toString(); String msg = muteReason.toString();
target.mute(muteTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma")); target.mute(muteTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma"));
Message.team("MUTE_TEAM_MUTED", target.getUserName(), sender.getName(), new Message((args[1].equalsIgnoreCase("perma")?"BAN_PERMA":"BAN_UNTIL"), muteTime), msg); Message.team("MUTE_TEAM_MUTED", new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((args[1].equalsIgnoreCase("perma")?"BAN_PERMA":"BAN_UNTIL"), muteTime), msg);
} }
} }

Datei anzeigen

@ -43,7 +43,7 @@ public class WhoisCommand extends BasicCommand {
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){ if(args.length == 0){
Message.send("WHOIS_SYNTAX", player); Message.send("WHOIS_USAGE", player);
return; return;
} }

Datei anzeigen

@ -43,7 +43,7 @@ public class BanListener extends BasicListener {
if(user.isBanned()) { if(user.isBanned()) {
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress()); user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
event.setCancelled(true); event.setCancelled(true);
event.setCancelReason(user.banMessage((ProxiedPlayer) event.getConnection())); event.setCancelReason(user.banMessage(ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
return; return;
} }

Datei anzeigen

@ -43,12 +43,15 @@ public class Punishment {
} }
public static Map<PunishmentType, Punishment> getPunishmentsOfPlayer(int user) { public static Map<PunishmentType, Punishment> getPunishmentsOfPlayer(int user) {
Map<PunishmentType, Punishment> punishments = new HashMap<>(); ResultSet set = SQL.select("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) WHERE UserId = ? GROUP BY Type)", user);
Punishment banPunishment = getPunishmentOfPlayer(user, PunishmentType.Ban); try {
if(banPunishment != null) punishments.put(PunishmentType.Ban, banPunishment); Map<PunishmentType, Punishment> punishments = new HashMap<>();
Punishment mutePunishment = getPunishmentOfPlayer(user, PunishmentType.Mute); while (set.next())
if(mutePunishment != null) punishments.put(PunishmentType.Mute, mutePunishment); punishments.put(PunishmentType.valueOf(set.getString("Type")), new Punishment(set));
return punishments; return punishments;
} catch (SQLException e) {
throw new SecurityException("Could not Load Punishments", e);
}
} }
public static List<Punishment> getAllPunishmentsOfPlayer(int user) { public static List<Punishment> getAllPunishmentsOfPlayer(int user) {
@ -119,6 +122,8 @@ public class Punishment {
} }
public void updateEndTime(int from, String newreason, Timestamp newUpdate, boolean perma) { public void updateEndTime(int from, String newreason, Timestamp newUpdate, boolean perma) {
if(newreason.equals(reason) && newUpdate.equals(endTime) && perma == perma)
return;
ProxiedPlayer player = BungeeCore.get().getProxy().getPlayer(SteamwarUser.get(from).getUuid()); ProxiedPlayer player = BungeeCore.get().getProxy().getPlayer(SteamwarUser.get(from).getUuid());
String newReason = Message.parse("BAN_CHANGED", player, reason, String newReason = Message.parse("BAN_CHANGED", player, reason,
SteamwarUser.get(from).getUserName(), SteamwarUser.get(from).getUserName(),
@ -139,6 +144,10 @@ public class Punishment {
return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")); return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"));
} }
public boolean isCurrent() {
return isPerma() || getEndTime().after(new Date());
}
public enum PunishmentType { public enum PunishmentType {
Ban, Ban,
Mute; Mute;

Datei anzeigen

@ -33,9 +33,7 @@ import java.net.UnknownHostException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.Instant;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -71,7 +69,7 @@ public class SteamwarUser {
usersById.put(id, this); usersById.put(id, this);
usersByName.put(userName.toLowerCase(), this); usersByName.put(userName.toLowerCase(), this);
usersByUUID.put(uuid, this); usersByUUID.put(uuid, this);
punishments = null; punishments = Punishment.getPunishmentsOfPlayer(id);
} }
public static SteamwarUser getOrCreate(PendingConnection connection){ public static SteamwarUser getOrCreate(PendingConnection connection){
@ -151,17 +149,10 @@ public class SteamwarUser {
return team; return team;
} }
private void loadPunishments() {
if(punishments == null) {
punishments = Punishment.getPunishmentsOfPlayer(id);
}
}
public boolean isBanned() { public boolean isBanned() {
loadPunishments();
if(!punishments.containsKey(Punishment.PunishmentType.Ban)) if(!punishments.containsKey(Punishment.PunishmentType.Ban))
return false; return false;
if(!isCurrent(punishments.get(Punishment.PunishmentType.Ban))) { if(!punishments.get(Punishment.PunishmentType.Ban).isCurrent()) {
SQL.update("DELETE FROM BannedUserIPs WHERE UserID = ?", id); SQL.update("DELETE FROM BannedUserIPs WHERE UserID = ?", id);
punishments.remove(Punishment.PunishmentType.Ban); punishments.remove(Punishment.PunishmentType.Ban);
return false; return false;
@ -170,18 +161,16 @@ public class SteamwarUser {
} }
public boolean isMuted(){ public boolean isMuted(){
loadPunishments();
if(!punishments.containsKey(Punishment.PunishmentType.Mute)) if(!punishments.containsKey(Punishment.PunishmentType.Mute))
return false; return false;
return isCurrent(punishments.get(Punishment.PunishmentType.Mute)); if(!punishments.get(Punishment.PunishmentType.Mute).isCurrent()) {
} punishments.remove(Punishment.PunishmentType.Mute);
return false;
private boolean isCurrent(Punishment punishment) { }
return punishment.isPerma() || punishment.getEndTime().after(new Date()); return true;
} }
public TextComponent banMessage(ProxiedPlayer player){ public TextComponent banMessage(ProxiedPlayer player){
loadPunishments();
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban); Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
if (punishment.isPerma()) { if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason())); return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
@ -192,7 +181,6 @@ public class SteamwarUser {
} }
public TextComponent muteMessage(ProxiedPlayer player){ public TextComponent muteMessage(ProxiedPlayer player){
loadPunishments();
Punishment punishment = punishments.get(Punishment.PunishmentType.Mute); Punishment punishment = punishments.get(Punishment.PunishmentType.Mute);
if (punishment.isPerma()) { if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason())); return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason()));
@ -206,7 +194,6 @@ public class SteamwarUser {
} }
public void ban(Timestamp time, String banReason, int from, boolean perma){ public void ban(Timestamp time, String banReason, int from, boolean perma){
loadPunishments();
if(isBanned()) { if(isBanned()) {
punishments.get(Punishment.PunishmentType.Ban).updateEndTime(from, banReason, time, perma); punishments.get(Punishment.PunishmentType.Ban).updateEndTime(from, banReason, time, perma);
return; return;
@ -229,7 +216,6 @@ public class SteamwarUser {
} }
public void mute(Timestamp time, String muteReason, int from, boolean perma){ public void mute(Timestamp time, String muteReason, int from, boolean perma){
loadPunishments();
if(isMuted()) { if(isMuted()) {
punishments.get(Punishment.PunishmentType.Mute).updateEndTime(from, muteReason, time, perma); punishments.get(Punishment.PunishmentType.Mute).updateEndTime(from, muteReason, time, perma);
return; return;

Datei anzeigen

@ -88,8 +88,6 @@ HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück
HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen
HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena
HELP_BAU_TESTARENA_HOVER=§eTestarena starten HELP_BAU_TESTARENA_HOVER=§eTestarena starten
HELP_BAU_BAU=§8/§ehelp bau §8- §7Hilfe zu nützlichen Werkzeugen
HELP_BAU_BAU_HOVER=§eNützliche Zusatzfunktionen
#Usage description of various commands #Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§eNachricht§8] USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
@ -107,14 +105,14 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War
ALERT=§f{0} ALERT=§f{0}
#Ban&Mute-Command #Ban&Mute-Command
BAN_TEAM_BANNED=§8[§4☣§8]» §c{0} wurde von {1} {2} gebannt. §f§lGrund: §f{3} BAN_TEAM_BANNED={0}§c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}
BANNED_MESSAGE_PERMA=§cDu bist permanent gebannt. §r§lGrund§r: §c{0} BANNED_MESSAGE_PERMA=§cDu bist permanent gebannt. §r§lGrund§r: §c{0}
BANNED_MESSAGE_UNTIL=§cDu bist bis zum {0} gebannt. §r§lGrund§r: §c{1} BANNED_MESSAGE_UNTIL=§cDu bist bis zum {0} gebannt. §r§lGrund§r: §c{1}
MUTE_TEAM_MUTED=§8[§4☣§8]» §c{0} wurde von {1} {2} gemuted. §f§lGrund: §f{3} MUTE_TEAM_MUTED={0}§c{1} wurde von {2} {3} gemuted. §f§lGrund: §f{4}
MUTED_MESSAGE_PERMA=§cDu bist permanent gemuted. §r§lGrund§r: §c{0} MUTED_MESSAGE_PERMA=§cDu bist permanent gemuted. §r§lGrund§r: §c{0}
MUTED_MESSAGE_UNTIL=§cDu bist bis zum {0} gemuted. §r§lGrund§r: §c{1} MUTED_MESSAGE_UNTIL=§cDu bist bis zum {0} gemuted. §r§lGrund§r: §c{1}
BAN_CHANGED={0}verändert von {1} von {2} auf {3} wegen {4} BAN_CHANGED={0}verändert von {1} von {2} auf {3} wegen {4}
BAN_PERMA=Permanent BAN_PERMA=permanent
BAN_UNTIL=bis zum {0} BAN_UNTIL=bis zum {0}
BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: §c BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: §c
BAN_AVOIDING_LIST={0} §e{1} §c BAN_AVOIDING_LIST={0} §e{1} §c
@ -164,7 +162,7 @@ CHECK_DECLINED=§cDein §e{0} {1} §cwurde abgelehnt§8: §c{2}
CHECK_DECLINED_TEAM=§7Die Schematic §e{0} §7von §e{1} §awurde aufgrund von §e{2} §7abgelehnt! CHECK_DECLINED_TEAM=§7Die Schematic §e{0} §7von §e{1} §awurde aufgrund von §e{2} §7abgelehnt!
#WhoisCommand #WhoisCommand
WHOIS_SYNTAX=§c/whois [Spieler/ID] WHOIS_USAGE=§c/whois [Spieler/ID]
WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_USERNAME=§7Username§8: §e{0}
WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0}
WHOIS_UUID_HOVER=§eUUID Kopieren WHOIS_UUID_HOVER=§eUUID Kopieren