Archiviert
1
0

Add punishment implementations

Dieser Commit ist enthalten in:
yoyosource 2021-09-27 09:29:51 +02:00
Ursprung 0b6b2c6b6b
Commit bb9627b74c
16 geänderte Dateien mit 103 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -162,8 +162,10 @@ public class BungeeCore extends Plugin {
Team.clearCache();
}, 1, 1, TimeUnit.HOURS);
if (SteamwarDiscordBotConfig.loaded) {
new SteamwarDiscordBot();
}
}
@Override
public void onDisable(){
@ -275,7 +277,9 @@ public class BungeeCore extends Plugin {
);
ArenaMode.init(config.getSection("games"));
if (config.getSection("discord") != null) {
SteamwarDiscordBotConfig.loadConfig(config.getSection("discord"));
}
final Configuration servers = config.getSection("servers");
for(final String serverName : servers.getKeys()){

Datei anzeigen

@ -194,6 +194,9 @@ public abstract class Node {
} catch (IOException e) {
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read cores of" + remote, e);
c = 1;
} catch (NumberFormatException e) {
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read cores of" + remote, e);
c = 1;
}
cores = c;
BungeeCore.get().getLogger().log(Level.INFO, "Adding node " + remote + " with " + cores + " cores.");

Datei anzeigen

@ -29,6 +29,7 @@ import java.util.Map;
public class SteamwarDiscordBotConfig {
public static boolean loaded = false;
public static String TOKEN;
public static String GUILD;
public static String ANNOUNCEMENTS_CHANNEL;
@ -110,5 +111,6 @@ public class SteamwarDiscordBotConfig {
for (String type : ranksSections.getKeys()) {
RANKS.put(UserGroup.getUsergroup(type), ranksSections.getString(type));
}
loaded = true;
}
}

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bungeecore.comms.packets.BaumemberUpdatePacket;
import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -38,8 +39,15 @@ public class BauCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
if(!(sender instanceof ProxiedPlayer)) {
return;
}
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiBauJoin)) {
return;
}
ProxiedPlayer p = (ProxiedPlayer) sender;

Datei anzeigen

@ -22,6 +22,8 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
@ -39,6 +41,12 @@ public class ChallengeCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiFightJoin)) {
return;
}
if(args.length < 1){
Message.send("CHALLENGE_USAGE", sender);
return;

Datei anzeigen

@ -20,6 +20,8 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
@ -45,6 +47,13 @@ public class DevCommand extends BasicCommand {
if (!(sender instanceof ProxiedPlayer)) {
return;
}
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiBauJoin)) {
return;
}
String[] devServer = DevServerDir.list();
if (devServer == null || devServer.length == 0) {
Message.send("DEV_NO_SERVER", sender);

Datei anzeigen

@ -21,6 +21,8 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
@ -163,6 +165,12 @@ public class FightCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiFightJoin)) {
return;
}
createArena(sender, "/fight ", args, 0, false, (player, mode, map) -> {
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false);
arena.sendPlayer(player);

Datei anzeigen

@ -20,8 +20,11 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.LinkedList;
@ -32,6 +35,12 @@ public class HistoricCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiFightJoin)) {
return;
}
FightCommand.createArena(sender, "/historic ", args, 0, true, (player, mode, map) -> {
Subserver arena = SubserverSystem.startArena(mode, map, 0, 0, 0, null, null, player.getUniqueId(), null, false);
arena.sendPlayer(player);

Datei anzeigen

@ -49,8 +49,7 @@ public class MsgCommand extends BasicCommand {
}
SteamwarUser user = SteamwarUser.get(player);
if (user.isPunished(Punishment.PunishmentType.Mute)) {
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, player));
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
return;
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import java.sql.Timestamp;
@ -29,10 +30,12 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
import java.util.logging.Level;
public class PunishmentCommand {
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
BungeeCord.getInstance().getLogger().log(Level.INFO, "CMD: " + command + " " + punishmentType);
new BasicCommand(command, "bungeecore.ban") {
@Override
public void execute(CommandSender sender, String[] args) {

Datei anzeigen

@ -45,8 +45,7 @@ public class RCommand extends BasicCommand {
}
SteamwarUser user = SteamwarUser.get(player);
if (user.isPunished(Punishment.PunishmentType.Mute)) {
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, player));
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
return;
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.Elo;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
@ -49,11 +50,20 @@ public class RankedCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer)) {
return;
}
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer);
if (steamwarUser.isPunishedWithMessage(proxiedPlayer, Punishment.PunishmentType.AntiFightJoin)) {
return;
}
if(args.length < 1){
getModes(sender, "/ranked ");
return;
}else if(!(sender instanceof ProxiedPlayer))
return;
}
ArenaMode mode = FightCommand.getMode(sender, args[0]);
if(mode == null)

Datei anzeigen

@ -145,8 +145,7 @@ public class ChatListener extends BasicListener {
}
SteamwarUser user = SteamwarUser.get(sender);
if (user.isPunished(Punishment.PunishmentType.Mute)) {
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, sender));
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
e.setCancelled(true);
return;
}
@ -224,8 +223,7 @@ public class ChatListener extends BasicListener {
}
SteamwarUser user = SteamwarUser.get(sender);
if (user.isPunished(Punishment.PunishmentType.Mute)) {
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, sender));
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
e.setCancelled(true);
return;
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bungeecore.bot.util.DiscordRanks;
import de.steamwar.bungeecore.commands.ChallengeCommand;
import de.steamwar.bungeecore.commands.CheckCommand;
import de.steamwar.bungeecore.commands.MsgCommand;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.api.AbstractReconnectHandler;
@ -34,10 +35,7 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerDisconnectEvent;
import net.md_5.bungee.api.event.ServerKickEvent;
import net.md_5.bungee.api.event.*;
import net.md_5.bungee.event.EventHandler;
import java.util.*;
@ -144,4 +142,24 @@ public class ConnectionListener extends BasicListener {
if(players.isEmpty() || (players.size() == 1 && players.contains(player)))
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination);
}
@EventHandler
public void onServerConnect(ServerConnectEvent e) {
ServerInfo server = e.getTarget();
Subserver subserver = Subserver.getSubserver(server);
if (subserver == null) {
return;
}
SteamwarUser steamwarUser = SteamwarUser.get(e.getPlayer());
if (subserver.getType() == Servertype.BAUSERVER) {
if (steamwarUser.isPunishedWithMessage(e.getPlayer(), Punishment.PunishmentType.AntiBauJoin)) {
e.setCancelled(true);
}
} else {
if (steamwarUser.isPunishedWithMessage(e.getPlayer(), Punishment.PunishmentType.AntiFightJoin)) {
e.setCancelled(true);
}
}
}
}

Datei anzeigen

@ -34,7 +34,6 @@ public class Punishment {
private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
private static final Statement getAllPunishments = new Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC");
private static final Statement insert = new Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)");
private static final Statement update = new Statement("UPDATE Punishments SET EndTime = ?, Reason = ?, Perma = ? WHERE PunishmentId = ?");
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
return getPunishment.select(rs -> {

Datei anzeigen

@ -267,6 +267,14 @@ public class SteamwarUser {
return true;
}
public boolean isPunishedWithMessage(ProxiedPlayer player, Punishment.PunishmentType punishment) {
if (!isPunished(punishment)) {
return false;
}
player.sendMessage(punishmentMessage(punishment, player));
return true;
}
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
punishments.remove(punishment);
punishments.put(punishment, Punishment.createPunishment(id, from, punishment, banReason, time, perma));