Archiviert
1
0

Fix forge autoban disconnect

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-06 18:09:00 +01:00
Ursprung 50ee5c6e95
Commit c88ac55b89

Datei anzeigen

@ -38,6 +38,7 @@ import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors;
class Utils { class Utils {
private Utils(){} private Utils(){}
@ -81,25 +82,22 @@ class Utils {
if(mods.isEmpty()) if(mods.isEmpty())
return true; return true;
if(mods.size() == 1){ ModType finalMax = max;
if(max == ModType.YELLOW) String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_SING", locale, mods.get(0).getModName()))); String message;
else{
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", locale, mods.get(0).getModName()), 0, false);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen des Mods " + mods.get(0).getModName() + " gebannt.");
}
}else{
StringBuilder sb = new StringBuilder();
mods.forEach(mod -> sb.append(mod.getModName()).append('\n'));
if(max == ModType.YELLOW) if(mods.size() == 1) {
disconnect.accept(TextComponent.fromLegacyText(Message.parse("MOD_YELLOW_PLUR", locale, sb.toString()))); message = Message.parse(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList);
else{ } else {
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", locale, sb.toString()), 0, false); message = Message.parse(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb + " gebannt.");
}
} }
if(max == ModType.RED) {
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
}
disconnect.accept(TextComponent.fromLegacyText(message));
return false; return false;
} }