From 4f7ccf20283a2d1bf7651df25fe2ae7b73dfcb8f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 2 Oct 2021 21:24:32 +0200 Subject: [PATCH] Fix stuff --- .../bungeecore/commands/FightCommand.java | 2 -- .../bungeecore/commands/HistoricCommand.java | 8 +++---- .../commands/PunishmentCommand.java | 7 ++----- .../bungeecore/commands/RankedCommand.java | 1 - .../listeners/ConnectionListener.java | 15 ++++--------- .../steamwar/bungeecore/sql/Punishment.java | 21 ++++++++++--------- 6 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 45e40a1..984bc06 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -21,8 +21,6 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/src/de/steamwar/bungeecore/commands/HistoricCommand.java b/src/de/steamwar/bungeecore/commands/HistoricCommand.java index c144795..0ddfef2 100644 --- a/src/de/steamwar/bungeecore/commands/HistoricCommand.java +++ b/src/de/steamwar/bungeecore/commands/HistoricCommand.java @@ -19,12 +19,12 @@ package de.steamwar.bungeecore.commands; -import de.steamwar.bungeecore.*; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.ArenaMode; +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.SubserverSystem; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.LinkedList; diff --git a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java index d214e7b..eda5c8b 100644 --- a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java +++ b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java @@ -22,7 +22,6 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -31,16 +30,14 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Instant; import java.util.Date; -import java.util.logging.Level; public class PunishmentCommand { public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) { - BungeeCord.getInstance().getLogger().log(Level.INFO, "CMD: " + command + " " + punishmentType); new BasicCommand(command, "bungeecore.ban") { @Override public void execute(CommandSender sender, String[] args) { - if (punishmentType == Punishment.PunishmentType.NoDevServer && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { + if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { return; } if (args.length < 3) { @@ -70,7 +67,7 @@ public class PunishmentCommand { new BasicCommand(antiCommand, "bungeecore.ban") { @Override public void execute(CommandSender sender, String[] args) { - if (punishmentType == Punishment.PunishmentType.NoDevServer && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { + if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { return; } if (args.length < 1) { diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index c4318be..f1649cb 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -21,7 +21,6 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.sql.Elo; -import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index e006e8e..9506ea2 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -27,7 +27,6 @@ import de.steamwar.bungeecore.bot.util.DiscordRanks; import de.steamwar.bungeecore.commands.ChallengeCommand; import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.commands.MsgCommand; -import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserGroup; import net.md_5.bungee.api.AbstractReconnectHandler; @@ -35,7 +34,10 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.*; +import net.md_5.bungee.api.event.PlayerDisconnectEvent; +import net.md_5.bungee.api.event.PostLoginEvent; +import net.md_5.bungee.api.event.ServerDisconnectEvent; +import net.md_5.bungee.api.event.ServerKickEvent; import net.md_5.bungee.event.EventHandler; import java.util.*; @@ -142,13 +144,4 @@ public class ConnectionListener extends BasicListener { if(players.isEmpty() || (players.size() == 1 && players.contains(player))) ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination); } - - @EventHandler - public void onServerConnect(ServerConnectEvent e) { - ServerInfo server = e.getTarget(); - Subserver subserver = Subserver.getSubserver(server); - if (subserver == null) { - return; - } - } } diff --git a/src/de/steamwar/bungeecore/sql/Punishment.java b/src/de/steamwar/bungeecore/sql/Punishment.java index 872e646..02b2dea 100644 --- a/src/de/steamwar/bungeecore/sql/Punishment.java +++ b/src/de/steamwar/bungeecore/sql/Punishment.java @@ -129,16 +129,17 @@ public class Punishment { @AllArgsConstructor @Getter public enum PunishmentType { - Ban("BAN_TEAM_BANNED", "BANNED_MESSAGE_PERMA", "BANNED_MESSAGE_UNTIL", "UNBAN_NOT_BANNED", "UNBAN_UNBANNED"), - Mute( "MUTE_TEAM_MUTED", "MUTED_MESSAGE_PERMA", "MUTED_MESSAGE_UNTIL", "UNMUTE_NOT_MUTED", "UNMUTE_UNMUTED"), - NoSchemReceiving("NOSCHEMRECEIVING_TEAM_NOSCHEMRECEIVING", "NOSCHEMRECEIVING_MESSAGE_PERMA", "NOSCHEMRECEIVING_MESSAGE_UNTIL", "UNNOSCHEMRECEIVING_NOT_NOSCHEMRECEIVING", "UNNOSCHEMRECEIVING_UNNOSCHEMRECEIVING"), - NoSchemSharing("NOSCHEMSHARING_TEAM_NOSCHEMSHARING", "NOSCHEMSHARING_MESSAGE_PERMA", "NOSCHEMSHARING_MESSAGE_UNTIL", "UNNOSCHEMSHARING_NOT_NOSCHEMSHARING", "UNNOSCHEMSHARING_UNNOSCHEMSHARING"), - NoDevServer("NODEVSERVER_TEAM_NODEVSERVER", "NODEVSERVER_MESSAGE_PERMA", "NODEVSERVER_MESSAGE_UNTIL", "UNNODEVSERVER_NOT_NODEVSERVER", "UNNODEVSERVER_UNNODEVSERVER"); + Ban(false, "BAN_TEAM_BANNED", "BANNED_MESSAGE_PERMA", "BANNED_MESSAGE_UNTIL", "UNBAN_NOT_BANNED", "UNBAN_UNBANNED"), + Mute( false, "MUTE_TEAM_MUTED", "MUTED_MESSAGE_PERMA", "MUTED_MESSAGE_UNTIL", "UNMUTE_NOT_MUTED", "UNMUTE_UNMUTED"), + NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM_NOSCHEMRECEIVING", "NOSCHEMRECEIVING_MESSAGE_PERMA", "NOSCHEMRECEIVING_MESSAGE_UNTIL", "UNNOSCHEMRECEIVING_NOT_NOSCHEMRECEIVING", "UNNOSCHEMRECEIVING_UNNOSCHEMRECEIVING"), + NoSchemSharing(false, "NOSCHEMSHARING_TEAM_NOSCHEMSHARING", "NOSCHEMSHARING_MESSAGE_PERMA", "NOSCHEMSHARING_MESSAGE_UNTIL", "UNNOSCHEMSHARING_NOT_NOSCHEMSHARING", "UNNOSCHEMSHARING_UNNOSCHEMSHARING"), + NoDevServer(true, "NODEVSERVER_TEAM_NODEVSERVER", "NODEVSERVER_MESSAGE_PERMA", "NODEVSERVER_MESSAGE_UNTIL", "UNNODEVSERVER_NOT_NODEVSERVER", "UNNODEVSERVER_UNNODEVSERVER"); - private String teamMessage; - private String playerMessagePerma; - private String playerMessageUntil; - private String usageNotPunished; - private String unpunishmentMessage; + private final boolean needsAdmin; + private final String teamMessage; + private final String playerMessagePerma; + private final String playerMessageUntil; + private final String usageNotPunished; + private final String unpunishmentMessage; } }