SteamWar/BungeeCore
Archiviert
13
2

Ban System Rework #150

Manuell gemergt
Lixfel hat 38 Commits von ban-rework nach master 2021-01-30 08:42:35 +01:00 zusammengeführt
7 geänderte Dateien mit 163 neuen und 48 gelöschten Zeilen
Nur Änderungen aus Commit 5fb8a617a7 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bungeecore.listeners.*;
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.listeners.mods.Forge;
import de.steamwar.bungeecore.listeners.mods.LabyMod;
import de.steamwar.bungeecore.listeners.mods.WorldDownloader;
import de.steamwar.bungeecore.sql.SQL;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
@ -85,6 +86,7 @@ public class BungeeCore extends Plugin {
new BanListener();
new CheckListener();
new ModLoaderBlocker();
new WorldDownloader();
commands.put("/b", null);
commands.put("/gs", null);

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
@ -37,6 +36,6 @@ public class AlertCommand extends BasicCommand {
return;
}
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', BungeeCore.CHAT_PREFIX + String.join(" ", args)));
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', String.join(" ", args)));
}
}

Datei anzeigen

@ -68,7 +68,7 @@ public class CheckCommand extends BasicCommand {
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
List<Schematic> schematics = getSchemsToCheck();
if(schematics.size() != currentCheckers.size())
ServerTeamchatCommand.sendToTeam("§7Es sind §e" + (schematics.size() - currentCheckers.size()) + " §7Schematics zu prüfen§8!");
Message.team("CHECK_REMINDER", schematics.size() - currentCheckers.size());
}, 10, 10, TimeUnit.MINUTES);
}
@ -91,7 +91,7 @@ public class CheckCommand extends BasicCommand {
schematic(player, args[1]);
break;
case "next":
case "allow":
case "accept":
next(player, args);
break;
case "cancel":
@ -118,27 +118,27 @@ public class CheckCommand extends BasicCommand {
private void list(ProxiedPlayer player) {
List<Schematic> schematicList = getSchemsToCheck();
BungeeCore.send(player, "§e§lZu prüfen sind " + schematicList.size() + " Schematics");
Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size());
for (Schematic schematic : schematicList) {
CheckSession current = currentSchems.get(schematic.getSchemID());
if (current == null) {
BungeeCore.send(player,
"§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName(),
"§eSchematic prüfen",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemID()));
Message.sendPrefixless("CHECK_LIST_TO_CHECK", player,
Message.parse("CHECK_LIST_TO_CHECK_HOVER", player),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemID()),
schematic.getSchemType().getKuerzel(), SteamwarUser.get(schematic.getSchemOwner()).getUserName(), schematic.getSchemName());
} else {
BungeeCore.send(player,
"§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName() + " §7wird geprüft von §e" + current.checker.getName(),
"§eZum Prüfer",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.getName()));
Message.sendPrefixless("CHECK_LIST_CHECKING", player,
Message.parse("CHECK_LIST_CHECKING_HOVER", player),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.getName()),
schematic.getSchemType().getKuerzel(), SteamwarUser.get(schematic.getSchemOwner()).getUserName(), schematic.getSchemName(), current.checker.getName());
}
}
}
private void schematic(ProxiedPlayer player, String schemID){
if(isChecking(player)){
BungeeCore.send(player, "§cDu prüfst schon eine Schematic!");
Message.send("CHECK_SCHEMATIC_ALREADY_CHECKING", player);
return;
}
@ -147,7 +147,7 @@ public class CheckCommand extends BasicCommand {
ProxyServer.getInstance().getLogger().log(Level.SEVERE, player.getName() + " tried to check an uncheckable schematic!");
return;
}else if(schem.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
BungeeCore.send(player, "§cDu kannst nicht deine eigenen Schematics prüfen");
Message.send("CHECK_SCHEMATIC_OWN", player);
return;
}
@ -156,7 +156,7 @@ public class CheckCommand extends BasicCommand {
private static boolean notChecking(ProxiedPlayer player){
if(!isChecking(player)){
BungeeCore.send(player, "§cDu prüfst derzeit nicht.");
Message.send("CHECK_NOT_CHECKING", player);
return true;
}
return false;
@ -171,7 +171,7 @@ public class CheckCommand extends BasicCommand {
try{
rank = Integer.parseInt(args[1]);
}catch(NumberFormatException e){
BungeeCore.send(player, "Der angegebene Rang ist ungültig!");
Message.send("CHECK_INVALID_RANK", player);
return;
}
}
@ -183,7 +183,7 @@ public class CheckCommand extends BasicCommand {
if(notChecking(player))
return;
BungeeCore.send(player, "§aDer Prüfvorgang wurde abgebrochen!");
Message.send("CHECK_ABORT", player);
currentCheckers.get(player.getUniqueId()).abort();
}
@ -204,11 +204,10 @@ public class CheckCommand extends BasicCommand {
}
private void help(CommandSender sender){
BungeeCore.send(sender, "§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics");
BungeeCore.send(sender, "§8/§echeck next §8- §7Nächste Prüffrage");
BungeeCore.send(sender, "§8/§echeck allow §8- §7Schematic freigeben");
BungeeCore.send(sender, "§8/§echeck decline [Grund] §8- §7Schematic nicht freigeben");
BungeeCore.send(sender, "§8/§echeck cancel §8- §7Bricht das Prüfen ab");
Message.sendPrefixless("CHECK_HELP_LIST", sender);
Message.sendPrefixless("CHECK_HELP_NEXT", sender);
Message.sendPrefixless("CHECK_HELP_DECLINE", sender);
Message.sendPrefixless("CHECK_HELP_CANCEL", sender);
}
private static class CheckSession{
@ -235,6 +234,8 @@ public class CheckCommand extends BasicCommand {
SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
currentCheckers.put(checker.getUniqueId(), this);
currentSchems.put(schematic.getSchemID(), this);
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic.getSchemName(), schematic.getSchemOwner()))
Message.sendPrefixless("CHECK_SCHEMATIC_PREVIOUS", checker, previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getReason());
next(0);
});
}
@ -245,26 +246,28 @@ public class CheckCommand extends BasicCommand {
return;
}
BungeeCore.send(checker, checkList.next());
checker.sendMessage(TextComponent.fromLegacyText(checkList.next()));
TextComponent next;
TextComponent next = new TextComponent();
next.setColor(ChatColor.GREEN);
if(checkList.hasNext()){
next = new TextComponent("next ");
next.setText(Message.parse("CHECK_NEXT", checker));
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
}else if(ranks.containsKey(schematic.getSchemType())){
next = new TextComponent();
List<String> r = ranks.get(schematic.getSchemType());
for(int i = 0; i < r.size(); i++){
BungeeCore.send(checker, "§aRang " + (i+1) + ": " + r.get(i), "§aMit diesem Rang freigeben", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow " + (i+1)));
BungeeCore.send(checker, "");
Message.sendPrefixless("CHECK_RANK", checker,
Message.parse("CHECK_RANK_HOVER", checker),
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check accept " + (i+1)),
i+1, r.get(i));
Message.sendPrefixless("SPACER", checker);
}
}else{
next = new TextComponent("accept ");
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
next.setText(Message.parse("CHECK_ACCEPT", checker));
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check accept"));
}
next.setColor(ChatColor.GREEN);
TextComponent decline = new TextComponent("decline");
TextComponent decline = new TextComponent(" " + Message.parse("CHECK_DECLINE", checker));
decline.setColor(ChatColor.RED);
decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline "));
@ -275,7 +278,7 @@ public class CheckCommand extends BasicCommand {
private void accept(int rank){
if(ranks.containsKey(schematic.getSchemType())){
if(rank <= 0 || ranks.get(schematic.getSchemType()).size() < rank){
BungeeCore.send(checker, "§cUnbekannter Schematic-Rang");
Message.send("CHECK_INVALID_RANK", checker);
return;
}
schematic.setRank(rank);
@ -283,24 +286,31 @@ public class CheckCommand extends BasicCommand {
schematic.setSchemType(schematic.getSchemType().fightType());
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
SteamwarUser user = SteamwarUser.get(schematic.getSchemOwner());
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
if(player != null)
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §ewurde freigegeben§8!");
ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!");
abort();
Message.send("CHECK_ACCEPTED", player, schematic.getSchemType().name(), schematic.getSchemName());
Message.team("CHECK_ACCEPTED_TEAM", schematic.getSchemName(), user.getUserName());
stop();
}
private void decline(String reason){
schematic.setSchemType(SchematicType.Normal);
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
SteamwarUser user = SteamwarUser.get(schematic.getSchemOwner());
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
if(player != null)
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §cwurde abgelehnt§8: §c" + reason);
ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §awurde aufgrund von §e" + reason + " §aabgelehnt!");
abort();
Message.send("CHECK_DECLINED", player, schematic.getSchemType().name(), schematic.getSchemName(), reason);
Message.team("CHECK_DECLINED_TEAM", schematic.getSchemName(), user.getUserName(), reason);
stop();
}
private void abort(){
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "Prüfvorgang abgebrochen");
stop();
}
private void stop(){
currentCheckers.remove(checker.getUniqueId());
currentSchems.remove(schematic.getSchemID());
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {

Datei anzeigen

@ -33,7 +33,6 @@ import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.event.EventHandler;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ -52,7 +51,7 @@ public class BanListener extends BasicListener {
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
if(!ips.isEmpty()){
Timestamp highestBan = Timestamp.from(Instant.now());
Timestamp highestBan = ips.get(0).getTimestamp();
for(BannedUserIPs banned : ips) {
if(highestBan.before(banned.getTimestamp()))
highestBan = banned.getTimestamp();
@ -70,8 +69,8 @@ public class BanListener extends BasicListener {
for(BannedUserIPs banned : ips) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getId(),
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT), bannedUser.getUserName()));
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getUserName(),
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT)));
}
TextComponent msg = new TextComponent(potentialBan.toString());

Datei anzeigen

@ -0,0 +1,33 @@
package de.steamwar.bungeecore.listeners.mods;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod;
import net.md_5.bungee.api.connection.Connection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.Collections;
import java.util.Set;
public class WorldDownloader extends BasicListener {
private static final Set<String> wdlTags = Collections.unmodifiableSet(
Sets.newHashSet("WDL|INIT", "wdl:init", "WDL|REQUEST", "wdl:request")
);
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent event){
if(!wdlTags.contains(event.getTag()))
return;
Connection sender = event.getSender();
if(!(sender instanceof ProxiedPlayer))
return;
event.setCancelled(true);
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.get("wdl", Mod.Platform.FORGE)));
}
}

Datei anzeigen

@ -19,13 +19,57 @@
package de.steamwar.bungeecore.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
public class CheckedSchematic {
private CheckedSchematic(){}
private final String schemName;
private final int schemOwner;
private final int validator;
private final Timestamp startTime;
private final Timestamp endTime;
private final String reason;
private CheckedSchematic(ResultSet rs) throws SQLException {
schemName = rs.getString("SchemName");
schemOwner = rs.getInt("SchemOwner");
validator = rs.getInt("Validator");
startTime = rs.getTimestamp("StartTime");
endTime = rs.getTimestamp("EndTime");
reason = rs.getString("DeclineReason");
}
public static void create(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String reason){
SQL.update("INSERT INTO CheckedSchematic (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?)",
schemName, schemOwner, validator, startTime, endTime, reason);
}
public static List<CheckedSchematic> previousChecks(String schemName, int schemOwner){
ResultSet rs = SQL.select("SELECT * FROM CheckedSchematic WHERE SchemName = ? AND SchemOwner = ? ORDER BY EndTime ASC", schemName, schemOwner);
List<CheckedSchematic> schematics = new ArrayList<>();
try {
while(rs.next())
schematics.add(new CheckedSchematic(rs));
} catch (SQLException e) {
throw new SecurityException("Could not load previous checks", e);
}
return schematics;
}
public int getValidator() {
return validator;
}
public Timestamp getEndTime() {
return endTime;
}
public String getReason() {
return reason;
}
}

Datei anzeigen

@ -1,4 +1,5 @@
PREFIX=§eSteam§8War»
SPACER=
Review

Das TIMEFORMAT sollte hier nicht eingespeichert werden müssen (ist ja auch nur das deutsche Timeformat)

Das TIMEFORMAT sollte hier nicht eingespeichert werden müssen (ist ja auch nur das deutsche Timeformat)
UNKNOWN_COMMAND=§cUnbekannter Befehl.
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
@ -124,4 +125,31 @@ POLLRESULT_LIST=§e{0}§8: §7{1}
#BauCommand
BAU_DELETE_GUI_NAME=§eWirklich Welt löschen?
BAU_DELETE_GUI_CANCEL=§cAbbrechen
BAU_DELETE_GUI_DELETE=§aLöschen
BAU_DELETE_GUI_DELETE=§aLöschen
#CheckCommand
CHECK_REMINDER=§7Es sind §e{0} §7Schematics zu prüfen§8!
CHECK_NOT_CHECKING=§cDu prüfst derzeit nicht.
CHECK_HELP_LIST=§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics
CHECK_HELP_NEXT=§8/§echeck next §8- §7Nächste Prüffrage§8/§7freigeben
CHECK_HELP_DECLINE=§8/§echeck decline §8[§eGrund§8] - §7Schematic ablehnen
CHECK_HELP_CANCEL=§8/§echeck cancel §8- §7Bricht den Prüfvorgang ab
CHECK_LIST_HEADER=§e§lZu prüfen sind {0} Schematics
CHECK_LIST_TO_CHECK=§8{0} §7{1} §e{2}
CHECK_LIST_TO_CHECK_HOVER=§eSchematic prüfen
CHECK_LIST_CHECKING=§8{0} §7{1} §e{2} §7wird geprüft von §e{3}
CHECK_LIST_CHECKING_HOVER=§eZum Prüfer
CHECK_SCHEMATIC_ALREADY_CHECKING=§cDu prüfst schon eine Schematic!
CHECK_SCHEMATIC_OWN=§cDu kannst nicht deine eigenen Schematics prüfen.
CHECK_SCHEMATIC_PREVIOUS=§7{0} von {1}§8: §e{2}
CHECK_INVALID_RANK=§cUnbekannter Schematicrang.
CHECK_ABORT=§aDer Prüfvorgang wurde abgebrochen!
CHECK_NEXT=Nächste Frage
CHECK_ACCEPT=Annehmen
CHECK_DECLINE=Ablehnen
CHECK_RANK=§aRang {0}: {1}
CHECK_RANK_HOVER=§aMit diesem Rang freigeben
CHECK_ACCEPTED=§aDein §e{0} {1} §ewurde freigegeben§8!
CHECK_ACCEPTED_TEAM=§7Die Schematic §e{0} §7von §e{1} §7ist nun freigegeben!
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!