Update Punishment system
Simplify Punishment code overhead
Dieser Commit ist enthalten in:
Ursprung
f8d6b73c0f
Commit
3cfd3f5beb
@ -20,6 +20,9 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
|
import de.steamwar.bungeecore.bot.commands.BanCommand;
|
||||||
|
import de.steamwar.bungeecore.bot.commands.MuteCommand;
|
||||||
|
import de.steamwar.bungeecore.bot.commands.UnbanCommand;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.commands.*;
|
import de.steamwar.bungeecore.commands.*;
|
||||||
import de.steamwar.bungeecore.comms.SpigotReceiver;
|
import de.steamwar.bungeecore.comms.SpigotReceiver;
|
||||||
@ -28,6 +31,7 @@ import de.steamwar.bungeecore.listeners.mods.Forge;
|
|||||||
import de.steamwar.bungeecore.listeners.mods.LabyMod;
|
import de.steamwar.bungeecore.listeners.mods.LabyMod;
|
||||||
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||||
import de.steamwar.bungeecore.listeners.mods.WorldDownloader;
|
import de.steamwar.bungeecore.listeners.mods.WorldDownloader;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.Statement;
|
import de.steamwar.bungeecore.sql.Statement;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
@ -130,6 +134,10 @@ public class BungeeCore extends Plugin {
|
|||||||
new StatCommand();
|
new StatCommand();
|
||||||
new VerifyCommand();
|
new VerifyCommand();
|
||||||
|
|
||||||
|
// Punishment Commands:
|
||||||
|
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
||||||
|
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
|
||||||
|
|
||||||
if(!EVENT_MODE){
|
if(!EVENT_MODE){
|
||||||
new BauCommand();
|
new BauCommand();
|
||||||
new WebregisterCommand();
|
new WebregisterCommand();
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -49,7 +51,7 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
return;
|
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) {
|
if (time == null) {
|
||||||
event.reply("Angegebene Zeit invalide").setEphemeral(true).queue();
|
event.reply("Angegebene Zeit invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
@ -58,7 +60,7 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
String msg = event.getOption("reason").getAsString();
|
String msg = event.getOption("reason").getAsString();
|
||||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
||||||
|
|
||||||
target.ban(time, msg, sender.getId(), isPerma);
|
target.punish(Punishment.PunishmentType.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);
|
Message.team("BAN_TEAM_BANNED", 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();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
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 de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -50,7 +51,7 @@ public class MuteCommand extends BasicDiscordCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp time = BanCommand.parseTime(null, event.getOption("time").getAsString());
|
Timestamp time = PunishmentCommand.parseTime(null, event.getOption("time").getAsString());
|
||||||
if (time == null) {
|
if (time == null) {
|
||||||
event.reply("Angegebene Zeit invalide").setEphemeral(true).complete();
|
event.reply("Angegebene Zeit invalide").setEphemeral(true).complete();
|
||||||
return;
|
return;
|
||||||
@ -59,7 +60,7 @@ public class MuteCommand extends BasicDiscordCommand {
|
|||||||
String msg = event.getOption("reason").getAsString();
|
String msg = event.getOption("reason").getAsString();
|
||||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
||||||
|
|
||||||
target.mute(time, msg, sender.getId(), isPerma);
|
target.punish(Punishment.PunishmentType.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);
|
Message.team("MUTE_TEAM_MUTED", 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();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gemutet").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -47,12 +48,12 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target.isBanned()) {
|
if (!target.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).queue();
|
event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).queue();
|
||||||
return;
|
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();
|
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
@ -50,7 +51,7 @@ public class IngameChatListener extends BasicDiscordListener {
|
|||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (steamwarUser.isMuted() || steamwarUser.isBanned()) {
|
if (steamwarUser.isPunished(Punishment.PunishmentType.Mute) || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -48,8 +49,8 @@ public class MsgCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
if(user.isMuted()){
|
if (user.isPunished(Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(player));
|
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, player));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
108
src/de/steamwar/bungeecore/commands/PunishmentCommand.java
Normale Datei
108
src/de/steamwar/bungeecore/commands/PunishmentCommand.java
Normale Datei
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* 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 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 (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 (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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -44,8 +45,8 @@ public class RCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
if(user.isMuted()){
|
if (user.isPunished(Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(player));
|
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, player));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,10 +41,10 @@ public class BanListener extends BasicListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(LoginEvent event) {
|
public void onLogin(LoginEvent event) {
|
||||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||||
if(user.isBanned()) {
|
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
event.setCancelled(true);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class BanListener extends BasicListener {
|
|||||||
boolean perma = false;
|
boolean perma = false;
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
if(bannedUser.isBanned()) {
|
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
||||||
if(ban.isPerma()) {
|
if(ban.isPerma()) {
|
||||||
perma = true;
|
perma = true;
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.listeners.IngameChatListener;
|
|
||||||
import de.steamwar.bungeecore.commands.TpCommand;
|
import de.steamwar.bungeecore.commands.TpCommand;
|
||||||
import de.steamwar.bungeecore.comms.packets.PingPacket;
|
import de.steamwar.bungeecore.comms.packets.PingPacket;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
@ -145,8 +145,8 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
SteamwarUser user = SteamwarUser.get(sender);
|
||||||
if(user.isMuted()){
|
if (user.isPunished(Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(sender));
|
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, sender));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -224,8 +224,8 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
SteamwarUser user = SteamwarUser.get(sender);
|
||||||
if(user.isMuted()){
|
if (user.isPunished(Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(sender));
|
sender.sendMessage(user.punishmentMessage(Punishment.PunishmentType.Mute, sender));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.Mod;
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
import de.steamwar.bungeecore.sql.Mod.ModType;
|
import de.steamwar.bungeecore.sql.Mod.ModType;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ class Utils {
|
|||||||
if(max == ModType.YELLOW)
|
if(max == ModType.YELLOW)
|
||||||
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_SING", player, mods.get(0).getModName())));
|
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_SING", player, mods.get(0).getModName())));
|
||||||
else{
|
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.");
|
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen des Mods " + mods.get(0).getModName() + " gebannt.");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -85,7 +86,7 @@ class Utils {
|
|||||||
if(max == ModType.YELLOW)
|
if(max == ModType.YELLOW)
|
||||||
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_PLUR", player, sb.toString())));
|
player.disconnect(BungeeCore.stringToText(Message.parse("MOD_YELLOW_PLUR", player, sb.toString())));
|
||||||
else{
|
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.");
|
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + sb.toString() + " gebannt.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import lombok.AllArgsConstructor;
|
||||||
import de.steamwar.bungeecore.Message;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -39,7 +38,7 @@ public class Punishment {
|
|||||||
|
|
||||||
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
||||||
return getPunishment.select(rs -> {
|
return getPunishment.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return new Punishment(rs);
|
return new Punishment(rs);
|
||||||
return null;
|
return null;
|
||||||
}, user, type.name());
|
}, user, type.name());
|
||||||
@ -116,35 +115,34 @@ public class Punishment {
|
|||||||
return perma;
|
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) {
|
public String getBantime(Timestamp endTime, boolean perma) {
|
||||||
if(perma)
|
if (perma) {
|
||||||
return "permanent";
|
return "permanent";
|
||||||
else
|
} else {
|
||||||
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() {
|
public boolean isCurrent() {
|
||||||
return isPerma() || getEndTime().after(new Date());
|
return isPerma() || getEndTime().after(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
public enum PunishmentType {
|
public enum PunishmentType {
|
||||||
Ban,
|
Ban("BAN_TEAM_BANNED", "BANNED_MESSAGE_PERMA", "BANNED_MESSAGE_UNTIL", "UNBAN_NOT_BANNED", "UNBAN_UNBANNED"),
|
||||||
Mute;
|
Mute( "MUTE_TEAM_MUTED", "MUTED_MESSAGE_PERMA", "MUTED_MESSAGE_UNTIL", "UNMUTE_NOT_MUTED", "UNMUTE_UNMUTED"),
|
||||||
|
AntiSchemAdd("ANTISCHEMADD_TEAM_ANTISCHEMADD", "ANTISCHEMADD_MESSAGE_PERMA", "ANTISCHEMADD_MESSAGE_UNTIL", "UNANTISCHEMADD_NOT_ANTISCHEMADD", "UNANTISCHEMADD_UNANTISCHEMADDED"),
|
||||||
|
AntiSchemAdded("ANTISCHEMADDED_TEAM_ANTISCHEMADDED", "ANTISCHEMADDED_MESSAGE_PERMA", "ANTISCHEMADDED_MESSAGE_UNTIL", "UNANTISCHEMADDED_NOT_ANTISCHEMADDED", "UNANTISCHEMADDED_UNANTISCHEMADDED"),
|
||||||
|
// AntiSchemDownload("UNANTISCHEMDOWNLOAD_NOT_ANTISCHEMDOWNLOADED"),
|
||||||
|
// AntiSchemUpload("UNANTISCHEMUPLOAD_NOT_ANTISCHEMUPLOADED"),
|
||||||
|
// AntiBauJoin("UNANTIBAUJOIN_NOT_ANTIBAUJOINED");
|
||||||
|
;
|
||||||
|
|
||||||
|
private String teamMessage;
|
||||||
|
private String playerMessagePerma;
|
||||||
|
private String playerMessageUntil;
|
||||||
|
private String usageNotPunished;
|
||||||
|
private String unpunishmentMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,25 +97,27 @@ 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);
|
||||||
if(discordId != null)
|
if (discordId != null) {
|
||||||
usersByDiscord.put(discordId, this);
|
usersByDiscord.put(discordId, this);
|
||||||
|
}
|
||||||
punishments = Punishment.getPunishmentsOfPlayer(id);
|
punishments = Punishment.getPunishmentsOfPlayer(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser getOrCreate(PendingConnection connection){
|
public static SteamwarUser getOrCreate(PendingConnection connection) {
|
||||||
SteamwarUser user = SteamwarUser.get(connection.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(connection.getUniqueId());
|
||||||
|
|
||||||
if(user != null){
|
if (user != null) {
|
||||||
String userName = connection.getName();
|
String userName = connection.getName();
|
||||||
if(!user.userName.equals(userName)){
|
if (!user.userName.equals(userName)) {
|
||||||
updateName.update(userName, user.id);
|
updateName.update(userName, user.id);
|
||||||
WebregisterCommand.changeUsername(user.userName, userName);
|
WebregisterCommand.changeUsername(user.userName, userName);
|
||||||
user.userName = userName;
|
user.userName = userName;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName());
|
user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName());
|
||||||
if(user == null)
|
if (user == null) {
|
||||||
throw new SecurityException("user == null");
|
throw new SecurityException("user == null");
|
||||||
|
}
|
||||||
ConnectionListener.newPlayer(user.uuid);
|
ConnectionListener.newPlayer(user.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ public class SteamwarUser {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser getOrCreateOfflinePlayer(String name){
|
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
||||||
SteamwarUser user = SteamwarUser.get(name);
|
SteamwarUser user = SteamwarUser.get(name);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
return user;
|
return user;
|
||||||
@ -143,34 +145,37 @@ public class SteamwarUser {
|
|||||||
return get(uuid);
|
return get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(String userName){
|
public static SteamwarUser get(String userName) {
|
||||||
userName = userName.toLowerCase();
|
userName = userName.toLowerCase();
|
||||||
if(usersByName.containsKey(userName))
|
if (usersByName.containsKey(userName)) {
|
||||||
return usersByName.get(userName);
|
return usersByName.get(userName);
|
||||||
|
}
|
||||||
return byName.select(rs -> {
|
return byName.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return new SteamwarUser(rs);
|
return new SteamwarUser(rs);
|
||||||
return null;
|
return null;
|
||||||
}, userName);
|
}, userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(UUID uuid){
|
public static SteamwarUser get(UUID uuid) {
|
||||||
if(usersByUUID.containsKey(uuid))
|
if (usersByUUID.containsKey(uuid)) {
|
||||||
return usersByUUID.get(uuid);
|
return usersByUUID.get(uuid);
|
||||||
|
}
|
||||||
return byUUID.select(rs -> {
|
return byUUID.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return new SteamwarUser(rs);
|
return new SteamwarUser(rs);
|
||||||
return null;
|
return null;
|
||||||
}, uuid.toString());
|
}, uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(ProxiedPlayer player){
|
public static SteamwarUser get(ProxiedPlayer player) {
|
||||||
return get(player.getUniqueId());
|
return get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(int id){
|
public static SteamwarUser get(int id) {
|
||||||
if(usersById.containsKey(id))
|
if (usersById.containsKey(id)) {
|
||||||
return usersById.get(id);
|
return usersById.get(id);
|
||||||
|
}
|
||||||
return byID.select(rs -> {
|
return byID.select(rs -> {
|
||||||
rs.next();
|
rs.next();
|
||||||
return new SteamwarUser(rs);
|
return new SteamwarUser(rs);
|
||||||
@ -178,16 +183,16 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(Long discordId) {
|
public static SteamwarUser get(Long discordId) {
|
||||||
if(usersByDiscord.containsKey(discordId.toString()))
|
if (usersByDiscord.containsKey(discordId.toString()))
|
||||||
return usersByDiscord.get(discordId.toString());
|
return usersByDiscord.get(discordId.toString());
|
||||||
return byDiscord.select(rs -> {
|
return byDiscord.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return new SteamwarUser(rs);
|
return new SteamwarUser(rs);
|
||||||
return null;
|
return null;
|
||||||
}, discordId);
|
}, discordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCache(){
|
public static void clearCache() {
|
||||||
usersById.clear();
|
usersById.clear();
|
||||||
usersByName.clear();
|
usersByName.clear();
|
||||||
usersByUUID.clear();
|
usersByUUID.clear();
|
||||||
@ -205,7 +210,7 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTeam(int team){
|
public void setTeam(int team) {
|
||||||
this.team = team;
|
this.team = team;
|
||||||
updateTeam.update(team, id);
|
updateTeam.update(team, id);
|
||||||
setLeader(false);
|
setLeader(false);
|
||||||
@ -227,7 +232,7 @@ public class SteamwarUser {
|
|||||||
return userGroup;
|
return userGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTeam(){
|
public int getTeam() {
|
||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,89 +248,64 @@ public class SteamwarUser {
|
|||||||
usersByDiscord.remove(this.discordId);
|
usersByDiscord.remove(this.discordId);
|
||||||
this.discordId = discordId;
|
this.discordId = discordId;
|
||||||
updateDiscord.update(discordId, id);
|
updateDiscord.update(discordId, id);
|
||||||
if(discordId != null) {
|
if (discordId != null) {
|
||||||
usersByDiscord.put(discordId, this);
|
usersByDiscord.put(discordId, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned() {
|
public boolean isPunished(Punishment.PunishmentType punishment) {
|
||||||
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
|
if (!punishments.containsKey(punishment)) {
|
||||||
return false;
|
return false;
|
||||||
if(!punishments.get(Punishment.PunishmentType.Ban).isCurrent()) {
|
}
|
||||||
deleteIPs.update(id);
|
if (!punishments.get(punishment).isCurrent()) {
|
||||||
punishments.remove(Punishment.PunishmentType.Ban);
|
if (punishment == Punishment.PunishmentType.Ban) {
|
||||||
|
deleteIPs.update(id);
|
||||||
|
}
|
||||||
|
punishments.remove(punishment);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMuted(){
|
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
|
||||||
if(!punishments.containsKey(Punishment.PunishmentType.Mute))
|
punishments.remove(punishment);
|
||||||
return false;
|
punishments.put(punishment, Punishment.createPunishment(id, from, punishment, banReason, time, perma));
|
||||||
if(!punishments.get(Punishment.PunishmentType.Mute).isCurrent()) {
|
|
||||||
punishments.remove(Punishment.PunishmentType.Mute);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextComponent banMessage(ProxiedPlayer player){
|
if (punishment != Punishment.PunishmentType.Ban) {
|
||||||
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
|
|
||||||
if (punishment.isPerma()) {
|
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
|
|
||||||
} else {
|
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))),
|
|
||||||
punishment.getReason()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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()));
|
|
||||||
} else {
|
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), punishment.getReason()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateBanIP(String ip){
|
|
||||||
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;
|
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);
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||||
if(player != null){
|
if (player != null) {
|
||||||
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
||||||
player.disconnect(banMessage(player));
|
player.disconnect(punishmentMessage(punishment, player));
|
||||||
for (BannedUserIPs banned:
|
for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
||||||
BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
|
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
if(bannedUser.isBanned() && banned.getTimestamp().before(time))
|
if (isPunished(punishment) && banned.getTimestamp().before(time)) {
|
||||||
bannedUser.ban(time, banReason, from, perma);
|
bannedUser.punish(punishment, time, banReason, from, perma);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else
|
} else {
|
||||||
updateBanIP("");
|
updateBanIP("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mute(Timestamp time, String muteReason, int from, boolean perma){
|
public TextComponent punishmentMessage(Punishment.PunishmentType punishment, ProxiedPlayer player) {
|
||||||
if(isMuted()) {
|
Punishment currentPunishment = punishments.get(punishment);
|
||||||
punishments.get(Punishment.PunishmentType.Mute).updateEndTime(from, muteReason, time, perma);
|
if (currentPunishment.isPerma()) {
|
||||||
return;
|
return BungeeCore.stringToText(Message.parsePrefixed(punishment.getPlayerMessagePerma(), player, currentPunishment.getReason()));
|
||||||
|
} else {
|
||||||
|
return BungeeCore.stringToText(Message.parsePrefixed(punishment.getPlayerMessageUntil(), player, currentPunishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))), currentPunishment.getReason()));
|
||||||
}
|
}
|
||||||
punishments.remove(Punishment.PunishmentType.Mute);
|
}
|
||||||
punishments.put(Punishment.PunishmentType.Mute, Punishment.createPunishment(id, from, Punishment.PunishmentType.Mute, muteReason, time, perma));
|
|
||||||
|
public void updateBanIP(String ip) {
|
||||||
|
BannedUserIPs.banIP(this, ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOnlinetime() {
|
public double getOnlinetime() {
|
||||||
return getPlaytime.select(rs -> {
|
return getPlaytime.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return rs.getBigDecimal("Playtime").doubleValue();
|
return rs.getBigDecimal("Playtime").doubleValue();
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}, id);
|
}, id);
|
||||||
@ -333,7 +313,7 @@ public class SteamwarUser {
|
|||||||
|
|
||||||
public Timestamp getFirstjoin() {
|
public Timestamp getFirstjoin() {
|
||||||
return getFirstjoin.select(rs -> {
|
return getFirstjoin.select(rs -> {
|
||||||
if(rs.next())
|
if (rs.next())
|
||||||
return rs.getTimestamp("FirstJoin");
|
return rs.getTimestamp("FirstJoin");
|
||||||
return null;
|
return null;
|
||||||
}, id);
|
}, id);
|
||||||
|
@ -95,8 +95,6 @@ HELP_BAU_TESTARENA_HOVER=§eTestarena starten
|
|||||||
|
|
||||||
#Usage description of various commands
|
#Usage description of various commands
|
||||||
USAGE_ALERT=§8/§7alert §8[§eNachricht§8]
|
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]
|
USAGE_IGNORE=§8/§7ignore §8[§eSpieler§8]
|
||||||
|
|
||||||
#ModListener
|
#ModListener
|
||||||
@ -110,21 +108,50 @@ ALERT=§f{0}
|
|||||||
STAT_SERVER=§7Server §e{0}§8: §7Load §e{1} §7Serveranzahl §e{2}
|
STAT_SERVER=§7Server §e{0}§8: §7Load §e{1} §7Serveranzahl §e{2}
|
||||||
|
|
||||||
#Ban&Mute-Command
|
#Ban&Mute-Command
|
||||||
BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}
|
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_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund§r: §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={0} §c{1} wurde von {2} {3} gemuted. §f§lGrund: §f{4}
|
UNBAN_NOT_BANNED=§cDer Spieler ist nicht gebannt.
|
||||||
|
UNBAN_UNBANNED=Du hast {0} entbannt.
|
||||||
|
|
||||||
|
MUTE_TEAM_MUTED={0} §c{1} wurde von {2} {3} gemuted. §f§lGrund§r: §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}
|
UNMUTE_NOT_MUTED=§cDer Spieler ist nicht gemutet.
|
||||||
BAN_PERMA=permanent
|
UNMUTE_UNMUTED=Du hast {0} entmutet.
|
||||||
BAN_UNTIL=bis zum {0}
|
|
||||||
|
ANTISCHEMADD_TEAM_ANTISCHEMADD={0} §c{1} wurde von {2} {3} schem adden ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
ANTISCHEMADD_MESSAGE_PERMA=§cDu bist permanent vom schem adden ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
ANTISCHEMADD_MESSAGE_UNTIL=§cDu bist bis zum {0} vom schem adden ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
UNANTISCHEMADD_NOT_ANTISCHEMADD=§cDer Spieler ist nicht vom schem adden ausgeschlossen.
|
||||||
|
UNANTISCHEMADD_UNANTISCHEMADDED=Du hast {0} das schem adden zurückgegeben.
|
||||||
|
|
||||||
|
ANTISCHEMADDED_TEAM_ANTISCHEMADDED={0} §c{1} wurde von {2} {3} schem add ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
ANTISCHEMADDED_MESSAGE_PERMA=§cDu bist permanent vom schem add ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
ANTISCHEMADDED_MESSAGE_UNTIL=§cDu bist bis zum {0} vom schem add ausgeschlossen. §f§lGrund§r: §f{4}
|
||||||
|
UNANTISCHEMADDED_NOT_ANTISCHEMADDED=§cDer Spieler ist nicht vom schem add ausgeschlossen.
|
||||||
|
UNANTISCHEMADDED_UNANTISCHEMADDED=Du hast {0} das schem add zurückgegeben.
|
||||||
|
|
||||||
|
UNANTISCHEMDOWNLOAD_NOT_ANTISCHEMDOWNLOADED=§cDer Spieler ist nicht ausgeschlossen Schematics runterzuladen.
|
||||||
|
|
||||||
|
UNANTISCHEMUPLOAD_NOT_ANTISCHEMUPLOADED=§cDer Spieler ist nicht ausgeschlossen Schematics hochzuladen.
|
||||||
|
|
||||||
|
UNANTIBAUJOIN_NOT_ANTIBAUJOINED=§cDer Spieler ist nicht vom joinen von Baus ausgeschlossen.
|
||||||
|
|
||||||
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
|
||||||
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
|
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
|
||||||
|
|
||||||
|
#BugCommand
|
||||||
BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
|
BUG_MESSAGE=§7Dein Bugreport wurde gespeichert.
|
||||||
|
|
||||||
|
#IgnoreCommand
|
||||||
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
|
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?
|
||||||
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
|
IGNORE_ALREADY=§cDu ignorierst diesen Spieler bereits.
|
||||||
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
|
IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
|
||||||
@ -423,11 +450,6 @@ TP_USAGE=§8/§7tp §8[§eSpieler§8]
|
|||||||
TP_USAGE_EVENT=§8/§7tp §8[§eSpieler §7oder §eTeam§8]
|
TP_USAGE_EVENT=§8/§7tp §8[§eSpieler §7oder §eTeam§8]
|
||||||
TP_NOT_FOUND=§cKonnte das angegebene Ziel nicht finden.
|
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
|
#UnignoreCommand
|
||||||
UNIGNORE_USAGE=§8/§7unignore §8[§eSpieler§8]
|
UNIGNORE_USAGE=§8/§7unignore §8[§eSpieler§8]
|
||||||
UNIGNORE_NOT_PLAYER=§cDiesen Spieler gibt es nicht!
|
UNIGNORE_NOT_PLAYER=§cDiesen Spieler gibt es nicht!
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren