geforkt von SteamWar/BungeeCore
Merge remote-tracking branch 'origin/Punishment++'
# Conflicts: # src/de/steamwar/bungeecore/commands/DevCommand.java # src/de/steamwar/bungeecore/sql/SteamwarUser.java
Dieser Commit ist enthalten in:
Commit
bffbacc289
@ -28,6 +28,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;
|
||||||
@ -108,8 +109,6 @@ public class BungeeCore extends Plugin {
|
|||||||
new JoinmeCommand();
|
new JoinmeCommand();
|
||||||
new TpCommand();
|
new TpCommand();
|
||||||
new HelpCommand();
|
new HelpCommand();
|
||||||
new BanCommand();
|
|
||||||
new UnbanCommand();
|
|
||||||
new DenyCommand("watchcat", "wc");
|
new DenyCommand("watchcat", "wc");
|
||||||
new TeamCommand();
|
new TeamCommand();
|
||||||
new ServerTeamchatCommand();
|
new ServerTeamchatCommand();
|
||||||
@ -118,7 +117,6 @@ public class BungeeCore extends Plugin {
|
|||||||
new EventreloadCommand();
|
new EventreloadCommand();
|
||||||
new EventRescheduleCommand();
|
new EventRescheduleCommand();
|
||||||
new PollCommand();
|
new PollCommand();
|
||||||
new MuteCommand();
|
|
||||||
new BugCommand();
|
new BugCommand();
|
||||||
new WhoisCommand();
|
new WhoisCommand();
|
||||||
new RegelnCommand();
|
new RegelnCommand();
|
||||||
@ -131,6 +129,14 @@ 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);
|
||||||
|
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){
|
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,8 +60,8 @@ 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", 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,8 +60,8 @@ 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", 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -38,8 +38,9 @@ public class BauCommand extends BasicCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
if(!(sender instanceof ProxiedPlayer)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
|
@ -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.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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;
|
import static de.steamwar.bungeecore.Storage.challenges;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
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,6 +49,11 @@ public class DevCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
||||||
|
if (steamwarUser.isPunishedWithMessage(player, Punishment.PunishmentType.NoDevServer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
updateDevServers();
|
updateDevServers();
|
||||||
if(devServers.isEmpty()) {
|
if(devServers.isEmpty()) {
|
||||||
Message.send("DEV_NO_SERVER", sender);
|
Message.send("DEV_NO_SERVER", sender);
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
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.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
|
||||||
|
@ -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,7 @@ public class MsgCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
if(user.isMuted()){
|
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(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);
|
|
||||||
}
|
|
||||||
}
|
|
115
src/de/steamwar/bungeecore/commands/PunishmentCommand.java
Normale Datei
115
src/de/steamwar/bungeecore/commands/PunishmentCommand.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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,7 @@ public class RCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
if(user.isMuted()){
|
if (user.isPunishedWithMessage(player, Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(player));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,14 @@ public class RankedCommand extends BasicCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(!(sender instanceof ProxiedPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(args.length < 1){
|
if(args.length < 1){
|
||||||
getModes(sender, "/ranked ");
|
getModes(sender, "/ranked ");
|
||||||
return;
|
return;
|
||||||
}else if(!(sender instanceof ProxiedPlayer))
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
ArenaMode mode = FightCommand.getMode(sender, args[0]);
|
ArenaMode mode = FightCommand.getMode(sender, args[0]);
|
||||||
if(mode == null)
|
if(mode == null)
|
||||||
|
@ -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;
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
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 +146,7 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
SteamwarUser user = SteamwarUser.get(sender);
|
||||||
if(user.isMuted()){
|
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(sender));
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,8 +228,7 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = SteamwarUser.get(sender);
|
SteamwarUser user = SteamwarUser.get(sender);
|
||||||
if(user.isMuted()){
|
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) {
|
||||||
sender.sendMessage(user.muteMessage(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;
|
||||||
@ -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 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 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 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) {
|
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
||||||
return getPunishment.select(rs -> {
|
return getPunishment.select(rs -> {
|
||||||
@ -116,35 +114,33 @@ 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(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"),
|
||||||
Mute;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,9 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +150,9 @@ public class SteamwarUser {
|
|||||||
|
|
||||||
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);
|
||||||
@ -159,8 +161,9 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -173,8 +176,9 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -252,43 +256,57 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()) {
|
}
|
||||||
|
if (!punishments.get(punishment).isCurrent()) {
|
||||||
|
if (punishment == Punishment.PunishmentType.Ban) {
|
||||||
deleteIPs.update(id);
|
deleteIPs.update(id);
|
||||||
punishments.remove(Punishment.PunishmentType.Ban);
|
}
|
||||||
|
punishments.remove(punishment);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMuted(){
|
public boolean isPunishedWithMessage(ProxiedPlayer player, Punishment.PunishmentType punishment) {
|
||||||
if(!punishments.containsKey(Punishment.PunishmentType.Mute))
|
if (!isPunished(punishment)) {
|
||||||
return false;
|
|
||||||
if(!punishments.get(Punishment.PunishmentType.Mute).isCurrent()) {
|
|
||||||
punishments.remove(Punishment.PunishmentType.Mute);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
player.sendMessage(punishmentMessage(punishment, player));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent banMessage(ProxiedPlayer player){
|
public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) {
|
||||||
Punishment punishment = punishments.get(Punishment.PunishmentType.Ban);
|
punishments.remove(punishment);
|
||||||
if (punishment.isPerma()) {
|
punishments.put(punishment, Punishment.createPunishment(id, from, punishment, banReason, time, perma));
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_PERMA", player, punishment.getReason()));
|
|
||||||
|
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 {
|
} else {
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("BANNED_MESSAGE_UNTIL", player, punishment.getEndTime().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", player))),
|
updateBanIP("");
|
||||||
punishment.getReason()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent muteMessage(ProxiedPlayer player){
|
public TextComponent punishmentMessage(Punishment.PunishmentType punishment, ProxiedPlayer player) {
|
||||||
Punishment punishment = punishments.get(Punishment.PunishmentType.Mute);
|
Punishment currentPunishment = punishments.get(punishment);
|
||||||
if (punishment.isPerma()) {
|
if (currentPunishment.isPerma()) {
|
||||||
return BungeeCore.stringToText(Message.parsePrefixed("MUTED_MESSAGE_PERMA", player, punishment.getReason()));
|
return BungeeCore.stringToText(Message.parsePrefixed(punishment.getPlayerMessagePerma(), player, currentPunishment.getReason()));
|
||||||
} else {
|
} 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);
|
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() {
|
public double getOnlinetime() {
|
||||||
return getPlaytime.select(rs -> {
|
return getPlaytime.select(rs -> {
|
||||||
if (rs.next() && rs.getBigDecimal("Playtime") != null)
|
if (rs.next() && rs.getBigDecimal("Playtime") != null)
|
||||||
|
@ -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,56 @@ 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]
|
||||||
BANNED_MESSAGE_PERMA=§cDu bist permanent gebannt. §r§lGrund§r: §c{0}
|
UNPUNISHMENT_USAGE=§8/§7{0} §8[§eSpieler§8]
|
||||||
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}
|
PUNISHMENT_UNTIL=bis zum {0}
|
||||||
MUTED_MESSAGE_PERMA=§cDu bist permanent gemuted. §r§lGrund§r: §c{0}
|
PUNISHMENT_PERMA=permanent
|
||||||
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_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4}
|
||||||
BAN_PERMA=permanent
|
BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0}
|
||||||
BAN_UNTIL=bis zum {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_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
|
||||||
|
|
||||||
|
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.
|
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 +456,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