SteamWar/BungeeCore
Archiviert
13
2

Merge remote-tracking branch 'origin/Punishment++'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

# Conflicts:
#	src/de/steamwar/bungeecore/commands/DevCommand.java
#	src/de/steamwar/bungeecore/sql/SteamwarUser.java
Dieser Commit ist enthalten in:
Lixfel 2021-10-12 11:54:41 +02:00
Commit bffbacc289
22 geänderte Dateien mit 296 neuen und 341 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import de.steamwar.bungeecore.listeners.mods.Forge;
import de.steamwar.bungeecore.listeners.mods.LabyMod;
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
import de.steamwar.bungeecore.listeners.mods.WorldDownloader;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.Statement;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
@ -108,8 +109,6 @@ public class BungeeCore extends Plugin {
new JoinmeCommand();
new TpCommand();
new HelpCommand();
new BanCommand();
new UnbanCommand();
new DenyCommand("watchcat", "wc");
new TeamCommand();
new ServerTeamchatCommand();
@ -118,7 +117,6 @@ public class BungeeCore extends Plugin {
new EventreloadCommand();
new EventRescheduleCommand();
new PollCommand();
new MuteCommand();
new BugCommand();
new WhoisCommand();
new RegelnCommand();
@ -131,6 +129,14 @@ public class BungeeCore extends Plugin {
new StatCommand();
new VerifyCommand();
// Punishment Commands:
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
new PunishmentCommand("noschemreceiving", Punishment.PunishmentType.NoSchemReceiving);
new PunishmentCommand("noschemsharing", Punishment.PunishmentType.NoSchemSharing);
new PunishmentCommand("noschemsubmitting", Punishment.PunishmentType.NoSchemSubmitting);
new PunishmentCommand("nodev", Punishment.PunishmentType.NoDevServer);
if(!EVENT_MODE){
new BauCommand();
new WebregisterCommand();

Datei anzeigen

@ -20,6 +20,8 @@
package de.steamwar.bungeecore.bot.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.commands.PunishmentCommand;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
@ -49,7 +51,7 @@ public class BanCommand extends BasicDiscordCommand {
return;
}
Timestamp time = de.steamwar.bungeecore.commands.BanCommand.parseTime(null, event.getOption("time").getAsString());
Timestamp time = PunishmentCommand.parseTime(null, event.getOption("time").getAsString());
if (time == null) {
event.reply("Angegebene Zeit invalide").setEphemeral(true).queue();
return;
@ -58,8 +60,8 @@ public class BanCommand extends BasicDiscordCommand {
String msg = event.getOption("reason").getAsString();
boolean isPerma = event.getOption("time").getAsString().equals("perma");
target.ban(time, msg, sender.getId(), isPerma);
Message.team("BAN_TEAM_BANNED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
target.punish(Punishment.PunishmentType.Ban, time, msg, sender.getId(), isPerma);
Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
}
}

Datei anzeigen

@ -20,7 +20,8 @@
package de.steamwar.bungeecore.bot.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.commands.BanCommand;
import de.steamwar.bungeecore.commands.PunishmentCommand;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
@ -50,7 +51,7 @@ public class MuteCommand extends BasicDiscordCommand {
return;
}
Timestamp time = BanCommand.parseTime(null, event.getOption("time").getAsString());
Timestamp time = PunishmentCommand.parseTime(null, event.getOption("time").getAsString());
if (time == null) {
event.reply("Angegebene Zeit invalide").setEphemeral(true).complete();
return;
@ -59,8 +60,8 @@ public class MuteCommand extends BasicDiscordCommand {
String msg = event.getOption("reason").getAsString();
boolean isPerma = event.getOption("time").getAsString().equals("perma");
target.mute(time, msg, sender.getId(), isPerma);
Message.team("MUTE_TEAM_MUTED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
target.punish(Punishment.PunishmentType.Mute, time, msg, sender.getId(), isPerma);
Message.team("MUTE_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gemutet").setEphemeral(true).queue();
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.bot.commands;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
@ -47,12 +48,12 @@ public class UnbanCommand extends BasicDiscordCommand {
return;
}
if (!target.isBanned()) {
if (!target.isPunished(Punishment.PunishmentType.Ban)) {
event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).queue();
return;
}
target.ban(Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.bot.listeners;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.dv8tion.jda.api.MessageBuilder;
@ -50,7 +51,7 @@ public class IngameChatListener extends BasicDiscordListener {
event.getMessage().delete().queue();
return;
}
if (steamwarUser.isMuted() || steamwarUser.isBanned()) {
if (steamwarUser.isPunished(Punishment.PunishmentType.Mute) || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
event.getMessage().delete().queue();
return;
}

Datei anzeigen

@ -1,85 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
public class BanCommand extends BasicCommand {
public BanCommand() {
super("ban", "bungeecore.ban");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 3){
Message.send("USAGE_BAN", sender);
return;
}
SteamwarUser target = unsafeUser(sender, args[0]);
if(target == null)
return;
Timestamp banTime = parseTime(sender, args[1]);
if(banTime == null)
return;
StringBuilder banReason = new StringBuilder();
for (int i = 2; i < args.length; i++){
banReason.append(args[i]).append(" ");
}
boolean isPerma = args[1].equalsIgnoreCase("perma");
String msg = banReason.toString();
target.ban(banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma);
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){
if(arg.equalsIgnoreCase("perma")) {
return Timestamp.from(Instant.ofEpochSecond(946674800));
}else{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy_HH:mm");
try{
Date parsedDate = dateFormat.parse(arg);
return new java.sql.Timestamp(parsedDate.getTime());
}catch(ParseException e){
dateFormat = new SimpleDateFormat("dd.MM.yyyy");
try{
Date parsedDate = dateFormat.parse(arg.split("_")[0]);
return new java.sql.Timestamp(parsedDate.getTime());
}catch(ParseException exception){
if (sender != null) {
Message.send("INVALID_TIME", sender);
}
return null;
}
}
}
}
}

Datei anzeigen

@ -38,8 +38,9 @@ public class BauCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
if(!(sender instanceof ProxiedPlayer)) {
return;
}
ProxiedPlayer p = (ProxiedPlayer) sender;

Datei anzeigen

@ -27,7 +27,8 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedList;
import static de.steamwar.bungeecore.Storage.challenges;

Datei anzeigen

@ -20,6 +20,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.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -48,6 +49,11 @@ public class DevCommand extends BasicCommand {
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
SteamwarUser steamwarUser = SteamwarUser.get(player);
if (steamwarUser.isPunishedWithMessage(player, Punishment.PunishmentType.NoDevServer)) {
return;
}
updateDevServers();
if(devServers.isEmpty()) {
Message.send("DEV_NO_SERVER", sender);

Datei anzeigen

@ -19,7 +19,10 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.SubserverSystem;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
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;
@ -48,8 +49,7 @@ public class MsgCommand extends BasicCommand {
}
SteamwarUser user = SteamwarUser.get(player);
if(user.isMuted()){
sender.sendMessage(user.muteMessage(player));
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
return;
}

Datei anzeigen

@ -1,57 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import java.sql.Timestamp;
public class MuteCommand extends BasicCommand {
public MuteCommand() {
super("mute", "bungeecore.ban");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 3){
Message.send("USAGE_MUTE", sender);
return;
}
SteamwarUser target = unsafeUser(sender, args[0]);
if(target == null)
return;
Timestamp muteTime = BanCommand.parseTime(sender, args[1]);
if(muteTime == null)
return;
StringBuilder muteReason = new StringBuilder();
for (int i = 2; i < args.length; i++){
muteReason.append(args[i]).append(" ");
}
String msg = muteReason.toString();
target.mute(muteTime, msg, SteamwarUser.get(sender.getName()).getId(), args[1].equalsIgnoreCase("perma"));
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

@ -0,0 +1,115 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;
public class PunishmentCommand {
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
new BasicCommand(command, "bungeecore.ban") {
@Override
public void execute(CommandSender sender, String[] args) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 3) {
Message.send("PUNISHMENT_USAGE", sender, command);
return;
}
SteamwarUser target = unsafeUser(sender, args[0]);
if (target == null)
return;
Timestamp banTime = parseTime(sender, args[1]);
if (banTime == null)
return;
StringBuilder reason = new StringBuilder();
for (int i = 2; i < args.length; i++) {
reason.append(args[i]).append(" ");
}
boolean isPerma = args[1].equalsIgnoreCase("perma");
String msg = reason.toString();
target.punish(punishmentType, banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma);
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
}
};
String antiCommand = "un" + command;
new BasicCommand(antiCommand, "bungeecore.ban") {
@Override
public void execute(CommandSender sender, String[] args) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 1) {
Message.send("UNPUNISHMENT_USAGE", sender, antiCommand);
return;
}
SteamwarUser target = existingUser(sender, args[0]);
if (target == null)
return;
if (!target.isPunished(punishmentType)) {
Message.send(punishmentType.getUsageNotPunished(), sender);
return;
}
Message.send(punishmentType.getUnpunishmentMessage(), sender, target.getUserName());
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(sender.getName()).getId(), false);
}
};
}
public static Timestamp parseTime(CommandSender sender, String arg) {
if (arg.equalsIgnoreCase("perma")) {
return Timestamp.from(Instant.ofEpochSecond(946674800));
} else {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy_HH:mm");
try {
Date parsedDate = dateFormat.parse(arg);
return new java.sql.Timestamp(parsedDate.getTime());
} catch (ParseException e) {
dateFormat = new SimpleDateFormat("dd.MM.yyyy");
try {
Date parsedDate = dateFormat.parse(arg.split("_")[0]);
return new java.sql.Timestamp(parsedDate.getTime());
} catch (ParseException exception) {
if (sender != null) {
Message.send("INVALID_TIME", sender);
}
return null;
}
}
}
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
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.connection.ProxiedPlayer;
@ -44,8 +45,7 @@ public class RCommand extends BasicCommand {
}
SteamwarUser user = SteamwarUser.get(player);
if(user.isMuted()){
sender.sendMessage(user.muteMessage(player));
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
return;
}

Datei anzeigen

@ -49,11 +49,14 @@ public class RankedCommand extends BasicCommand {
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer)) {
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

@ -1,54 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import java.sql.Timestamp;
import java.util.Date;
public class UnbanCommand extends BasicCommand {
public UnbanCommand() {
super("unban", "bungeecore.ban");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 1){
Message.send("UNBAN_USAGE", sender);
return;
}
SteamwarUser target = existingUser(sender, args[0]);
if(target == null)
return;
if(!target.isBanned()) {
Message.send("UNBAN_NOT_BANNED", sender);
return;
}
Message.send("UNBAN_UNBANNED", sender, target.getUserName());
target.ban(Timestamp.from(new Date().toInstant()), "Unban", SteamwarUser.get(sender.getName()).getId(), false);
}
}

Datei anzeigen

@ -41,10 +41,10 @@ public class BanListener extends BasicListener {
@EventHandler
public void onLogin(LoginEvent event) {
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
if(user.isBanned()) {
if (user.isPunished(Punishment.PunishmentType.Ban)) {
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
event.setCancelled(true);
event.setCancelReason(user.banMessage(ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
event.setCancelReason(user.punishmentMessage(Punishment.PunishmentType.Ban, ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
return;
}
@ -55,7 +55,7 @@ public class BanListener extends BasicListener {
boolean perma = false;
for(BannedUserIPs banned : ips) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
if(bannedUser.isBanned()) {
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
if(ban.isPerma()) {
perma = true;

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.UserGroup;
@ -145,8 +146,7 @@ public class ChatListener extends BasicListener {
}
SteamwarUser user = SteamwarUser.get(sender);
if(user.isMuted()){
sender.sendMessage(user.muteMessage(sender));
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
e.setCancelled(true);
return;
}
@ -228,8 +228,7 @@ public class ChatListener extends BasicListener {
}
SteamwarUser user = SteamwarUser.get(sender);
if(user.isMuted()){
sender.sendMessage(user.muteMessage(sender));
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
e.setCancelled(true);
return;
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Mod;
import de.steamwar.bungeecore.sql.Mod.ModType;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -75,7 +76,7 @@ class Utils {
if(max == ModType.YELLOW)
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_SING", player, mods.get(0).getModName())));
else{
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", player, mods.get(0).getModName()), 0, false);
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_SING", player, 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{
@ -85,7 +86,7 @@ class Utils {
if(max == ModType.YELLOW)
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_PLUR", player, sb.toString())));
else{
user.ban(Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", player, sb.toString()), 0, false);
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), Message.parse("MOD_RED_PLUR", player, sb.toString()), 0, false);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb.toString() + " gebannt.");
}
}

Datei anzeigen

@ -19,9 +19,8 @@
package de.steamwar.bungeecore.sql;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -35,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 -> {
@ -116,35 +114,33 @@ public class Punishment {
return perma;
}
public void updateEndTime(int from, String newreason, Timestamp newUpdate, boolean perma) {
if(newreason.equals(reason) && newUpdate.equals(endTime) && this.perma == perma)
return;
ProxiedPlayer player = BungeeCore.get().getProxy().getPlayer(SteamwarUser.get(from).getUuid());
String newReason = Message.parse("BAN_CHANGED", player, reason,
SteamwarUser.get(from).getUserName(),
getBantime(endTime, this.perma),
getBantime(newUpdate, perma),
newreason);
update.update(newUpdate, newReason, perma, id);
this.reason = newReason;
this.perma = perma;
this.endTime = newUpdate;
}
public String getBantime(Timestamp endTime, boolean perma) {
if(perma)
if (perma) {
return "permanent";
else
} else {
return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"));
}
}
public boolean isCurrent() {
return isPerma() || getEndTime().after(new Date());
}
@AllArgsConstructor
@Getter
public enum PunishmentType {
Ban,
Mute;
Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"),
NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"),
NoSchemSharing(false, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"),
NoSchemSubmitting(true, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"),
NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER");
private final boolean needsAdmin;
private final String teamMessage;
private final String playerMessagePerma;
private final String playerMessageUntil;
private final String usageNotPunished;
private final String unpunishmentMessage;
}
}

Datei anzeigen

@ -118,8 +118,9 @@ public class SteamwarUser {
}
} else {
user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName());
if(user == null)
if (user == null) {
throw new SecurityException("user == null");
}
ConnectionListener.newPlayer(user.uuid);
}
@ -149,8 +150,9 @@ public class SteamwarUser {
public static SteamwarUser get(String userName) {
userName = userName.toLowerCase();
if(usersByName.containsKey(userName))
if (usersByName.containsKey(userName)) {
return usersByName.get(userName);
}
return byName.select(rs -> {
if (rs.next())
return new SteamwarUser(rs);
@ -159,8 +161,9 @@ public class SteamwarUser {
}
public static SteamwarUser get(UUID uuid) {
if(usersByUUID.containsKey(uuid))
if (usersByUUID.containsKey(uuid)) {
return usersByUUID.get(uuid);
}
return byUUID.select(rs -> {
if (rs.next())
return new SteamwarUser(rs);
@ -173,8 +176,9 @@ public class SteamwarUser {
}
public static SteamwarUser get(int id) {
if(usersById.containsKey(id))
if (usersById.containsKey(id)) {
return usersById.get(id);
}
return byID.select(rs -> {
rs.next();
return new SteamwarUser(rs);
@ -252,43 +256,57 @@ public class SteamwarUser {
}
}
public boolean isBanned() {
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
public boolean isPunished(Punishment.PunishmentType punishment) {
if (!punishments.containsKey(punishment)) {
return false;
if(!punishments.get(Punishment.PunishmentType.Ban).isCurrent()) {
}
if (!punishments.get(punishment).isCurrent()) {
if (punishment == Punishment.PunishmentType.Ban) {
deleteIPs.update(id);
punishments.remove(Punishment.PunishmentType.Ban);
}
punishments.remove(punishment);
return false;
}
return true;
}
public boolean isMuted(){
if(!punishments.containsKey(Punishment.PunishmentType.Mute))
return false;
if(!punishments.get(Punishment.PunishmentType.Mute).isCurrent()) {
punishments.remove(Punishment.PunishmentType.Mute);
public boolean isPunishedWithMessage(ProxiedPlayer player, Punishment.PunishmentType punishment) {
if (!isPunished(punishment)) {
return false;
}
player.sendMessage(punishmentMessage(punishment, player));
return true;
}
public TextComponent banMessage(ProxiedPlayer player){
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
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));
if (punishment != Punishment.PunishmentType.Ban) {
return;
}
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if (player != null) {
updateBanIP(player.getAddress().getAddress().getHostAddress());
player.disconnect(punishmentMessage(punishment, player));
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
if (isPunished(punishment) && banned.getTimestamp().before(time)) {
bannedUser.punish(punishment, time, banReason, from, perma);
}
}
} else {
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))),
punishment.getReason()));
updateBanIP("");
}
}
public TextComponent muteMessage(ProxiedPlayer player){
Punishment punishment = punishments.get(Punishment.PunishmentType.Mute);
if (punishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason()));
public TextComponent punishmentMessage(Punishment.PunishmentType punishment, ProxiedPlayer player) {
Punishment currentPunishment = punishments.get(punishment);
if (currentPunishment.isPerma()) {
return BungeeCore.stringToText(Message.parsePrefixed(punishment.getPlayerMessagePerma(), player, currentPunishment.getReason()));
} else {
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), punishment.getReason()));
return BungeeCore.stringToText(Message.parsePrefixed(punishment.getPlayerMessageUntil(), player, currentPunishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), currentPunishment.getReason()));
}
}
@ -296,37 +314,6 @@ public class SteamwarUser {
BannedUserIPs.banIP(this, ip);
}
public void ban(Timestamp time, String banReason, int from, boolean perma){
if(isBanned()) {
punishments.get(Punishment.PunishmentType.Ban).updateEndTime(from, banReason, time, perma);
return;
}
punishments.remove(Punishment.PunishmentType.Ban);
punishments.put(Punishment.PunishmentType.Ban, Punishment.createPunishment(id, from, Punishment.PunishmentType.Ban, banReason, time, perma));
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if(player != null){
updateBanIP(player.getAddress().getAddress().getHostAddress());
player.disconnect(banMessage(player));
for (BannedUserIPs banned:
BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
if(bannedUser.isBanned() && banned.getTimestamp().before(time))
bannedUser.ban(time, banReason, from, perma);
}
}else
updateBanIP("");
}
public void mute(Timestamp time, String muteReason, int from, boolean perma){
if(isMuted()) {
punishments.get(Punishment.PunishmentType.Mute).updateEndTime(from, muteReason, time, perma);
return;
}
punishments.remove(Punishment.PunishmentType.Mute);
punishments.put(Punishment.PunishmentType.Mute, Punishment.createPunishment(id, from, Punishment.PunishmentType.Mute, muteReason, time, perma));
}
public double getOnlinetime() {
return getPlaytime.select(rs -> {
if (rs.next() && rs.getBigDecimal("Playtime") != null)

Datei anzeigen

@ -95,8 +95,6 @@ HELP_BAU_TESTARENA_HOVER=§eTestarena starten
#Usage description of various commands
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
USAGE_BAN=§8/§7ban §8[§eSpieler§8] [§edd§8.§emm§8.§eyyyy §7oder §edd§8.§emm§8.§eyyyy§8_§ehh§8:§emm §7oder §eperma§8] [§eGrund§8]
USAGE_MUTE=§8/§7mute §8[§eSpieler§8] [§edd§8.§emm§8.§eyyyy §7oder §edd§8.§emm§8.§eyyyy§8_§ehh§8:§emm §7oder §eperma§8] [§eGrund§8]
USAGE_IGNORE=§8/§7ignore §8[§eSpieler§8]
#ModListener
@ -110,21 +108,56 @@ ALERT=§f{0}
STAT_SERVER=§7Server §e{0}§8: §7Load §e{1} §7Serveranzahl §e{2}
#Ban&Mute-Command
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_UNTIL=§cDu bist bis zum {0} gebannt. §r§lGrund§r: §c{1}
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_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_PERMA=permanent
BAN_UNTIL=bis zum {0}
PUNISHMENT_USAGE=§8/§7{0} §8[§eSpieler§8] [§edd§8.§emm§8.§eyyyy §7oder §edd§8.§emm§8.§eyyyy§8_§ehh§8:§emm §7oder §eperma§8] [§eGrund§8]
UNPUNISHMENT_USAGE=§8/§7{0} §8[§eSpieler§8]
PUNISHMENT_UNTIL=bis zum {0}
PUNISHMENT_PERMA=permanent
BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4}
BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0}
BAN_UNTIL=§7Du bist §ebis zum {0} §e§lgebannt§8. §7Grund§8: §e{1}
UNBAN_ERROR=§cDer Spieler ist nicht gebannt.
UNBAN=§7Du hast §e{0} §e§lentbannt.
BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: §c
BAN_AVOIDING_LIST={0} §e{1} §c
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
MUTE_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgemuted§8. §7Grund§8: §f{4}
MUTE_PERMA=§7Du bist §epermanent §e§lgemuted§8. §7Grund§8: §e{0}
MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1}
UNMUTE_ERROR=§cDer Spieler ist nicht gemuted.
UNMUTE=§7Du hast §e{0} §e§lentmuted.
NOSCHEMRECEIVING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicerhalten ausgeschlossen§8. §7Grund§8: §f{4}
NOSCHEMRECEIVING_PERMA=§7Du bist §epermanent §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{0}
NOSCHEMRECEIVING_UNTIL=§7Du bist §ebis zum {0} §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{1}
UNNOSCHEMRECEIVING_ERROR=§cDer Spieler ist nicht vom Erhalten von Schematics ausgeschlossen.
UNNOSCHEMRECEIVING=§e{0} §7darf nun wieder §e§lSchematics erhalten§8.
NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen ausgeschlossen§8. §7Grund§8: §f{4}
NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0}
NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1}
UNNOSCHEMSHARING_ERROR=§cDer Spieler ist nicht vom Verteilen von Schematics ausgeschlossen.
UNNOSCHEMSHARING=§e{0} §7darf nun wieder §e§lSchematics verteilen§8.
NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematiceinsenden ausgeschlossen§8. §7Grund§8: §f{4}
NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0}
NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1}
UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen.
UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis einsenden§8.
NODEVSERVER_TEAM={0} §e{1} §7hat §e{2} §7mit Grund §f{4}§7 zu generft und hat daher §e§lDevserververbot §7erhalten§8, §e{3}
NODEVSERVER_PERMA=§7Du bist §epermanent §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{0}
NODEVSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{1}
UNNODEVSERVER_ERROR=§cDer Spieler ist nicht vom Devserver ausgeschlossen.
UNNODEVSERVER=§e{0} §7darf nun wieder dem §e§lDevserver beitreten§8.
#BugCommand
BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
#IgnoreCommand
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
@ -423,11 +456,6 @@ TP_USAGE=§8/§7tp §8[§eSpieler§8]
TP_USAGE_EVENT=§8/§7tp §8[§eSpieler §7oder §eTeam§8]
TP_NOT_FOUND=§cKonnte das angegebene Ziel nicht finden.
#UnbanCommand
UNBAN_USAGE=§8/§7unban §8[§eSpieler§8]
UNBAN_NOT_BANNED=§cDer Spieler ist nicht gebannt.
UNBAN_UNBANNED=Du hast {0} entbannt.
#UnignoreCommand
UNIGNORE_USAGE=§8/§7unignore §8[§eSpieler§8]
UNIGNORE_NOT_PLAYER=§cDiesen Spieler gibt es nicht!