From c4bafb459186e000cf962baec7865422ce1c3c21 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 21 Feb 2023 18:22:42 +0100 Subject: [PATCH] WIP CommonDB: Milestone SWUser Signed-off-by: Lixfel --- CommonCore | 2 +- src/de/steamwar/bungeecore/BungeeCore.java | 7 +- src/de/steamwar/bungeecore/EventStarter.java | 6 +- src/de/steamwar/bungeecore/ServerStarter.java | 10 +- .../steamwar/bungeecore/SubserverSystem.java | 2 +- .../steamwar/bungeecore/bot/AuthManager.java | 2 +- .../bungeecore/bot/commands/BanCommand.java | 7 +- .../bot/commands/BasicDiscordCommand.java | 2 +- .../bungeecore/bot/commands/MuteCommand.java | 6 +- .../bungeecore/bot/commands/TeamCommand.java | 4 +- .../bungeecore/bot/commands/UnbanCommand.java | 9 +- .../bungeecore/bot/commands/WhoisCommand.java | 6 +- .../bungeecore/bot/events/EventManager.java | 2 +- .../bot/events/SchematicsManager.java | 2 +- .../bot/listeners/DiscordAuthListener.java | 2 +- .../bot/listeners/DiscordChatListener.java | 4 +- .../bot/listeners/DiscordEventListener.java | 2 +- .../bot/listeners/DiscordTicketListener.java | 4 +- .../bot/listeners/PrivateMessageListener.java | 5 +- .../bungeecore/bot/util/DiscordRanks.java | 2 +- .../bot/util/DiscordSchemAlert.java | 2 +- .../bungeecore/commands/BasicCommand.java | 4 +- .../bungeecore/commands/BauCommand.java | 30 +- .../bungeecore/commands/BugCommand.java | 2 +- .../bungeecore/commands/CalendarCommand.java | 4 +- .../bungeecore/commands/CheckCommand.java | 6 +- .../bungeecore/commands/DevCommand.java | 8 +- .../bungeecore/commands/EventCommand.java | 2 +- .../commands/EventRescheduleCommand.java | 2 +- .../commands/EventreloadCommand.java | 2 +- .../bungeecore/commands/FightCommand.java | 3 - .../bungeecore/commands/GDPRQuery.java | 14 +- .../bungeecore/commands/IgnoreCommand.java | 3 +- .../bungeecore/commands/ModCommand.java | 4 +- .../bungeecore/commands/PlaytimeCommand.java | 8 +- .../bungeecore/commands/PollCommand.java | 2 +- .../commands/PunishmentCommand.java | 95 ++++- .../bungeecore/commands/RankCommand.java | 3 +- .../bungeecore/commands/ReplayCommand.java | 10 +- .../bungeecore/commands/SetLocaleCommand.java | 3 + .../bungeecore/commands/TeamCommand.java | 12 +- .../bungeecore/commands/TeamchatCommand.java | 2 +- .../bungeecore/commands/TpCommand.java | 8 +- .../bungeecore/commands/TutorialCommand.java | 4 +- .../bungeecore/commands/TypeMappers.java | 5 +- .../bungeecore/commands/UnIgnoreCommand.java | 2 +- .../bungeecore/commands/VerifyCommand.java | 2 +- .../bungeecore/commands/WhoisCommand.java | 16 +- .../bungeecore/inventory/SWInventory.java | 10 +- .../bungeecore/listeners/BanListener.java | 16 +- .../bungeecore/listeners/ChatListener.java | 12 +- .../bungeecore/listeners/CheckListener.java | 2 +- .../listeners/ConnectionListener.java | 2 +- .../listeners/EventModeListener.java | 4 +- .../bungeecore/listeners/PollSystem.java | 2 +- .../bungeecore/listeners/SessionManager.java | 4 +- .../listeners/SettingsChangedListener.java | 8 +- .../bungeecore/listeners/mods/Fabric.java | 6 +- .../bungeecore/listeners/mods/Forge.java | 2 +- .../bungeecore/listeners/mods/Forge12.java | 2 +- .../bungeecore/listeners/mods/LabyMod.java | 2 +- .../bungeecore/listeners/mods/Utils.java | 10 +- .../listeners/mods/WorldDownloader.java | 2 +- .../handlers/ExecuteCommandHandler.java | 4 +- .../network/handlers/FightEndsHandler.java | 6 +- .../handlers/InventoryCallbackHandler.java | 6 +- .../network/handlers/PrepareSchemHandler.java | 4 +- .../bungeecore/sql/CheckedSchematic.java | 1 + .../steamwar/bungeecore/sql/EventFight.java | 150 ------- src/de/steamwar/bungeecore/sql/Fight.java | 145 ------- .../steamwar/bungeecore/sql/IgnoreSystem.java | 1 + src/de/steamwar/bungeecore/sql/Mod.java | 127 ------ .../steamwar/bungeecore/sql/NodeMember.java | 86 ---- .../steamwar/bungeecore/sql/Punishment.java | 160 ------- src/de/steamwar/bungeecore/sql/SchemElo.java | 52 --- .../bungeecore/sql/SchematicNode.java | 2 + .../steamwar/bungeecore/sql/SteamwarUser.java | 398 ------------------ src/de/steamwar/bungeecore/sql/Tutorial.java | 123 ------ src/de/steamwar/bungeecore/sql/UserElo.java | 1 + .../bungeecore/tablist/TablistPart.java | 2 +- .../bungeecore/tablist/TablistServer.java | 4 +- src/de/steamwar/bungeecore/util/BauLock.java | 4 +- src/de/steamwar/command/TypeUtils.java | 2 +- src/de/steamwar/messages/ChatSender.java | 2 +- 84 files changed, 278 insertions(+), 1430 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/sql/EventFight.java delete mode 100644 src/de/steamwar/bungeecore/sql/Fight.java delete mode 100644 src/de/steamwar/bungeecore/sql/Mod.java delete mode 100644 src/de/steamwar/bungeecore/sql/NodeMember.java delete mode 100644 src/de/steamwar/bungeecore/sql/Punishment.java delete mode 100644 src/de/steamwar/bungeecore/sql/SchemElo.java delete mode 100644 src/de/steamwar/bungeecore/sql/SteamwarUser.java delete mode 100644 src/de/steamwar/bungeecore/sql/Tutorial.java diff --git a/CommonCore b/CommonCore index 3e1c4e9..8dbf62e 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 3e1c4e9059ef2400c79aaa5089eaafca075640c6 +Subproject commit 8dbf62e560de95615d93057481e8202ec11c85c4 diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 1ff556b..f1aec11 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -28,9 +28,8 @@ import de.steamwar.bungeecore.listeners.ping.PingListener; import de.steamwar.bungeecore.network.BungeeNetworkHandler; import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.network.SWScriptSyntaxForwarder; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.Team; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserElo; import de.steamwar.bungeecore.tablist.TablistManager; import de.steamwar.command.SWCommandUtils; @@ -206,7 +205,7 @@ public class BungeeCore extends Plugin { new SettingsChangedListener(); getProxy().getScheduler().schedule(this, () -> { - SteamwarUser.clearCache(); + SteamwarUser.clear(); UserElo.clearCache(); Team.clear(); }, 1, 1, TimeUnit.HOURS); diff --git a/src/de/steamwar/bungeecore/EventStarter.java b/src/de/steamwar/bungeecore/EventStarter.java index 67a2d7e..ddf78bd 100644 --- a/src/de/steamwar/bungeecore/EventStarter.java +++ b/src/de/steamwar/bungeecore/EventStarter.java @@ -19,8 +19,8 @@ package de.steamwar.bungeecore; -import de.steamwar.bungeecore.sql.EventFight; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.EventFight; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.Event; import net.md_5.bungee.api.ProxyServer; @@ -66,7 +66,7 @@ public class EventStarter implements Runnable { if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) { ServerStarter starter = new ServerStarter().event(next); - ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUuid()); + ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUUID()); if(leiter != null) starter.send(leiter); diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 5ad9a6f..d2ec14f 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -1,9 +1,9 @@ package de.steamwar.bungeecore; -import de.steamwar.bungeecore.sql.EventFight; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.EventFight; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; -import de.steamwar.bungeecore.sql.Tutorial; +import de.steamwar.sql.Tutorial; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -67,13 +67,13 @@ public class ServerStarter { } public ServerStarter event(EventFight eventFight) { - arena(eventFight.getSpielmodus(), eventFight.getMap()); + arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap()); node = BungeeCore.local; worldDir = EVENT_PATH; worldCleanup = () -> {}; arguments.put("fightID", String.valueOf(eventFight.getFightID())); fightMap = eventFight.getMap(); - gameMode = eventFight.getSpielmodus().getInternalName(); + gameMode = eventFight.getSpielmodus(); String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel(); serverNameProvider = port -> serverName; diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 9842154..b751f6e 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.handlers.FightInfoHandler; import de.steamwar.bungeecore.sql.IgnoreSystem; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.server.StartingServerPacket; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; diff --git a/src/de/steamwar/bungeecore/bot/AuthManager.java b/src/de/steamwar/bungeecore/bot/AuthManager.java index ac4f553..8500f12 100644 --- a/src/de/steamwar/bungeecore/bot/AuthManager.java +++ b/src/de/steamwar/bungeecore/bot/AuthManager.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.entities.Member; diff --git a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java index e328997..ed6569e 100644 --- a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java @@ -21,8 +21,7 @@ package de.steamwar.bungeecore.bot.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.PunishmentCommand; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; @@ -45,7 +44,7 @@ public class BanCommand extends BasicDiscordCommand { } SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong()); - SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); + SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); if (target == null) { event.reply("Angegebener User invalide").setEphemeral(true).queue(); return; @@ -60,7 +59,7 @@ public class BanCommand extends BasicDiscordCommand { String msg = event.getOption("reason").getAsString(); boolean isPerma = event.getOption("time").getAsString().equals("perma"); - target.punish(Punishment.PunishmentType.Ban, time, msg, sender.getId(), isPerma); + PunishmentCommand.ban(target, time, msg, sender, isPerma); Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg); event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue(); } diff --git a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java index 00ec1b8..8dbb58b 100644 --- a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java @@ -19,7 +19,7 @@ package de.steamwar.bungeecore.bot.commands; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; diff --git a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java index 086cf77..3c296f4 100644 --- a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java @@ -21,8 +21,8 @@ package de.steamwar.bungeecore.bot.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.PunishmentCommand; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; @@ -45,7 +45,7 @@ public class MuteCommand extends BasicDiscordCommand { } SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong()); - SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); + SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); if (target == null) { event.reply("Angegebener User invalide").setEphemeral(true).complete(); return; diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java index b8c5d4e..c07dbf2 100644 --- a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.bot.commands; import de.steamwar.sql.Event; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; import net.dv8tion.jda.api.EmbedBuilder; @@ -91,6 +91,6 @@ public class TeamCommand extends BasicDiscordCommand { } private boolean isOnline(SteamwarUser user) { - return ProxyServer.getInstance().getPlayer(user.getUuid()) != null; + return ProxyServer.getInstance().getPlayer(user.getUUID()) != null; } } diff --git a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java index f8d6185..61d5c0d 100644 --- a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java @@ -19,8 +19,10 @@ package de.steamwar.bungeecore.bot.commands; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.commands.PunishmentCommand; +import de.steamwar.sql.BannedUserIPs; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; @@ -42,7 +44,7 @@ public class UnbanCommand extends BasicDiscordCommand { } SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong()); - SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); + SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString()); if (target == null) { event.reply("Angegebener User invalide").setEphemeral(true).queue(); return; @@ -54,6 +56,7 @@ public class UnbanCommand extends BasicDiscordCommand { } target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false); + BannedUserIPs.unbanIPs(target.getId()); event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue(); } } diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java index 0ce37b3..d253372 100644 --- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java @@ -19,8 +19,8 @@ package de.steamwar.bungeecore.bot.commands; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; @@ -72,7 +72,7 @@ public class WhoisCommand extends BasicDiscordCommand { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setTitle("Whois: " + user.getUserName()); StringBuilder st = new StringBuilder(); - st.append("UUID: ").append(user.getUuid()).append("\n"); + st.append("UUID: ").append(user.getUUID()).append("\n"); st.append("ID: ").append(user.getId()).append("\n"); if (user.getDiscordId() != null) { st.append("DiscordID: ").append(user.getDiscordId()).append("\n"); diff --git a/src/de/steamwar/bungeecore/bot/events/EventManager.java b/src/de/steamwar/bungeecore/bot/events/EventManager.java index 1cd09d3..884dd28 100644 --- a/src/de/steamwar/bungeecore/bot/events/EventManager.java +++ b/src/de/steamwar/bungeecore/bot/events/EventManager.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.events; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import de.steamwar.bungeecore.sql.EventFight; +import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.Event; diff --git a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java index e407cf9..e53bf9a 100644 --- a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java +++ b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore.bot.events; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.commands.CheckCommand; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java index 8ad3428..947ed5e 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.AuthManager; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; import net.dv8tion.jda.api.interactions.InteractionType; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java index 70004ac..13b5fca 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java @@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.listeners.ChatListener; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.messages.ChatSender; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Member; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java index c6f61e9..b21f427 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.bot.events.EventManager; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.Event; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java index f7a2fa2..525dd08 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java @@ -23,7 +23,7 @@ import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.bot.config.DiscordTicketType; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; @@ -138,7 +138,7 @@ public class DiscordTicketListener extends BasicDiscordListener { if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) { BungeeCore.get().getProxy().getPlayers().forEach(player -> { if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return; - SteamwarUser user = SteamwarUser.get(player); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); boolean sendMessage; if(user.getDiscordId() == null) { sendMessage = user.getUserGroup().isCheckSchematics(); diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java index 8aafe2f..0891c87 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java @@ -19,14 +19,13 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.sql.Punishment; +import de.steamwar.sql.Punishment; import de.steamwar.bungeecore.sql.SchematicNode; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; import java.io.InputStream; -import java.util.concurrent.CompletableFuture; public class PrivateMessageListener extends BasicDiscordListener { diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java b/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java index 7224576..e9ec857 100644 --- a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java +++ b/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Role; diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java index f0d9d7b..9d9e2c7 100644 --- a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java +++ b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.sql.SchematicNode; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; diff --git a/src/de/steamwar/bungeecore/commands/BasicCommand.java b/src/de/steamwar/bungeecore/commands/BasicCommand.java index d4b9c0a..bb62a6e 100644 --- a/src/de/steamwar/bungeecore/commands/BasicCommand.java +++ b/src/de/steamwar/bungeecore/commands/BasicCommand.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -61,7 +61,7 @@ abstract class BasicCommand extends Command implements TabExecutor { } protected SteamwarUser unsafeUser(CommandSender sender, String arg){ - SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg); + SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(arg); if(target == null) Message.send("UNKNOWN_PLAYER", sender); return target; diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index b73855f..9cc60da 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -23,7 +23,6 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.network.NetworkSender; -import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.util.BauLock; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.command.SWCommand; @@ -33,6 +32,7 @@ import de.steamwar.messages.ChatSender; import de.steamwar.network.packets.server.BaumemberUpdatePacket; import de.steamwar.bungeecore.util.BauLockState; import de.steamwar.sql.BauweltMember; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; @@ -123,10 +123,10 @@ public class BauCommand extends SWCommand { @Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE") public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) { - BauweltMember.addMember(p.getUniqueId(), target.getUuid()); + BauweltMember.addMember(p.getUniqueId(), target.getUUID()); Message.send("BAU_ADDMEMBER_ADDED", p); - ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid()); + ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUUID()); if(z != null) Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName()); } @@ -138,11 +138,11 @@ public class BauCommand extends SWCommand { messageSender.send("UNKNOWN_PLAYER"); return false; } - if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) { + if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) { messageSender.send("BAU_ADDMEMBER_SELFADD"); return false; } - if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUuid()) != null) { + if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUUID()) != null) { messageSender.send("BAU_ADDMEMBER_ISADDED"); return false; } @@ -154,9 +154,9 @@ public class BauCommand extends SWCommand { @Register("teleport") public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) { versionSelector(version, - () -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(), - () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), - () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start() + () -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(), + () -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(), + () -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start() ); } @@ -168,12 +168,12 @@ public class BauCommand extends SWCommand { return false; } ProxiedPlayer p = (ProxiedPlayer) sender; - if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) { - SubserverSystem.sendDeniedMessage(p, value.getUuid()); + if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) { + SubserverSystem.sendDeniedMessage(p, value.getUUID()); messageSender.send("BAU_TP_NOALLOWED"); return false; } - if(BauLock.isLocked(value, SteamwarUser.get(p))) { + if(BauLock.isLocked(value, SteamwarUser.get(p.getUniqueId()))) { messageSender.send("BAU_LOCKED_NOALLOWED"); return false; } @@ -232,13 +232,13 @@ public class BauCommand extends SWCommand { if (target == null) return; - if(SteamwarUser.get(target.getMemberID()).getUuid().equals(p.getUniqueId())) { + if(SteamwarUser.get(target.getMemberID()).getUUID().equals(p.getUniqueId())) { Message.send("BAU_DELMEMBER_SELFDEL", p); return; } target.remove(); - ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); + ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID()); if(toRemove != null){ Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName()); Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo()); @@ -309,7 +309,7 @@ public class BauCommand extends SWCommand { return null; } - BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUuid()); + BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUUID()); if (target == null) { Message.send("BAU_MEMBER_NOMEMBER", p); return null; @@ -318,7 +318,7 @@ public class BauCommand extends SWCommand { } private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){ - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID()); if(permission){ if(player != null) diff --git a/src/de/steamwar/bungeecore/commands/BugCommand.java b/src/de/steamwar/bungeecore/commands/BugCommand.java index b3e5990..f93e23d 100644 --- a/src/de/steamwar/bungeecore/commands/BugCommand.java +++ b/src/de/steamwar/bungeecore/commands/BugCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.sql.SWException; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/commands/CalendarCommand.java b/src/de/steamwar/bungeecore/commands/CalendarCommand.java index 5d203db..d3163ca 100644 --- a/src/de/steamwar/bungeecore/commands/CalendarCommand.java +++ b/src/de/steamwar/bungeecore/commands/CalendarCommand.java @@ -22,9 +22,9 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; -import de.steamwar.bungeecore.sql.NodeMember; +import de.steamwar.sql.NodeMember; import de.steamwar.bungeecore.sql.SchematicNode; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index 5cab0c2..521eef1 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -25,7 +25,7 @@ import de.steamwar.bungeecore.listeners.ConnectionListener; import de.steamwar.bungeecore.sql.CheckedSchematic; import de.steamwar.bungeecore.sql.SchematicNode; import de.steamwar.sql.SchematicType; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ProxyServer; @@ -279,7 +279,7 @@ public class CheckCommand extends SWCommand { schematic.setType(fightTypes.get(schematic.getSchemtype()).toDB()); SteamwarUser user = SteamwarUser.get(schematic.getOwner()); - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid()); + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID()); if(player != null) { Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName()); } else { @@ -293,7 +293,7 @@ public class CheckCommand extends SWCommand { private void decline(String reason){ if(createLog(reason)) { SteamwarUser user = SteamwarUser.get(schematic.getOwner()); - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid()); + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID()); if(player != null) { Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason); } else { diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java index 5858a49..834f96d 100644 --- a/src/de/steamwar/bungeecore/commands/DevCommand.java +++ b/src/de/steamwar/bungeecore/commands/DevCommand.java @@ -20,8 +20,8 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.*; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.ProxyServer; @@ -79,9 +79,9 @@ public class DevCommand extends SWCommand { @ClassValidator(value = ProxiedPlayer.class, local = true) public TypeValidator punishmentGuardChecker() { return (sender, value, messageSender) -> { - SteamwarUser user = SteamwarUser.get(value); + SteamwarUser user = SteamwarUser.get(value.getUniqueId()); if (user.isPunished(Punishment.PunishmentType.NoDevServer)) { - Message message = user.punishmentMessage(Punishment.PunishmentType.NoDevServer); + Message message = PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.NoDevServer); messageSender.send(message.getFormat(), message.getParams()); return false; } diff --git a/src/de/steamwar/bungeecore/commands/EventCommand.java b/src/de/steamwar/bungeecore/commands/EventCommand.java index 082b9b7..e71eeed 100644 --- a/src/de/steamwar/bungeecore/commands/EventCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; -import de.steamwar.bungeecore.sql.EventFight; +import de.steamwar.sql.EventFight; import de.steamwar.sql.SchematicType; import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; diff --git a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java index 16e98e1..13e8f59 100644 --- a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.EventFight; +import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; diff --git a/src/de/steamwar/bungeecore/commands/EventreloadCommand.java b/src/de/steamwar/bungeecore/commands/EventreloadCommand.java index 9d5008a..1c3d173 100644 --- a/src/de/steamwar/bungeecore/commands/EventreloadCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventreloadCommand.java @@ -19,7 +19,7 @@ package de.steamwar.bungeecore.commands; -import de.steamwar.bungeecore.sql.EventFight; +import de.steamwar.sql.EventFight; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.CommandSender; diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 5911db5..e5cf3e4 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -22,13 +22,10 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; -import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; -import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/de/steamwar/bungeecore/commands/GDPRQuery.java b/src/de/steamwar/bungeecore/commands/GDPRQuery.java index 25e37fa..0158edf 100644 --- a/src/de/steamwar/bungeecore/commands/GDPRQuery.java +++ b/src/de/steamwar/bungeecore/commands/GDPRQuery.java @@ -3,7 +3,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.sql.internal.Statement; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -25,7 +25,7 @@ public class GDPRQuery extends SWCommand { @Register public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) { - SteamwarUser user = SteamwarUser.get(forPlayer); + SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId()); if(user == null) { Message.send("UNKNOWN_PLAYER", player); return; @@ -49,7 +49,7 @@ public class GDPRQuery extends SWCommand { copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt"); printUpdate(player, "GDPR_STATUS_WORLD"); - copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUuid().toString(), "BuildWorld12"); + copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12"); copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15"); printUpdate(player, "GDPR_STATUS_INVENTORIES"); @@ -214,14 +214,14 @@ public class GDPRQuery extends SWCommand { } } - File playerdata = new File(world, "playerdata/" + user.getUuid().toString() + ".dat"); + File playerdata = new File(world, "playerdata/" + user.getUUID().toString() + ".dat"); if(playerdata.exists()) - copy(playerdata, out, outDir + "/playerdata/" + user.getUuid().toString() + ".dat"); + copy(playerdata, out, outDir + "/playerdata/" + user.getUUID().toString() + ".dat"); } private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException { File worlds = new File(inDir); - String path = "playerdata/" + user.getUuid().toString() + ".dat"; + String path = "playerdata/" + user.getUUID().toString() + ".dat"; int i = 0; for(File world : worlds.listFiles()) { @@ -229,7 +229,7 @@ public class GDPRQuery extends SWCommand { if(!playerdata.exists()) continue; - copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUuid().toString() + ".dat"); + copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat"); } } diff --git a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java index 0c11ee0..b7c26f7 100644 --- a/src/de/steamwar/bungeecore/commands/IgnoreCommand.java +++ b/src/de/steamwar/bungeecore/commands/IgnoreCommand.java @@ -21,12 +21,11 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.IgnoreSystem; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.stream.Collectors; diff --git a/src/de/steamwar/bungeecore/commands/ModCommand.java b/src/de/steamwar/bungeecore/commands/ModCommand.java index f5b4c66..ed6bbd7 100644 --- a/src/de/steamwar/bungeecore/commands/ModCommand.java +++ b/src/de/steamwar/bungeecore/commands/ModCommand.java @@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.inventory.SWStreamInv; -import de.steamwar.bungeecore.sql.*; import de.steamwar.command.SWCommand; +import de.steamwar.sql.Mod; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -39,7 +39,7 @@ public class ModCommand extends SWCommand { super("mod", "bungeecore.softreload", "mods"); } - public static final Map playerFilterType = new HashMap<>(); + public static final Map playerFilterType = new HashMap<>(); @Register public void genericCommand(ProxiedPlayer p) { diff --git a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java index c9c3850..c483ec9 100644 --- a/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java +++ b/src/de/steamwar/bungeecore/commands/PlaytimeCommand.java @@ -20,15 +20,11 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; -import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; -import org.apache.commons.lang3.LocaleUtils; -import java.text.DecimalFormat; import java.text.NumberFormat; -import java.util.Locale; public class PlaytimeCommand extends SWCommand { @@ -40,7 +36,7 @@ public class PlaytimeCommand extends SWCommand { public void genericCommand(ProxiedPlayer player) { NumberFormat format = NumberFormat.getNumberInstance((player).getLocale()); format.setMaximumFractionDigits(2); - String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600)); + String formattedText = format.format((SteamwarUser.get(player.getUniqueId()).getOnlinetime() / (double) 3600)); Message.send("HOURS_PLAYED", player, formattedText); } diff --git a/src/de/steamwar/bungeecore/commands/PollCommand.java b/src/de/steamwar/bungeecore/commands/PollCommand.java index 4e3a3bd..6cae84d 100644 --- a/src/de/steamwar/bungeecore/commands/PollCommand.java +++ b/src/de/steamwar/bungeecore/commands/PollCommand.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.listeners.PollSystem; import de.steamwar.sql.PollAnswer; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java index 62e9831..23ba5f2 100644 --- a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java +++ b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java @@ -19,13 +19,20 @@ package de.steamwar.bungeecore.commands; +import com.google.gson.JsonParser; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; +import de.steamwar.messages.ChatSender; +import de.steamwar.sql.BannedUserIPs; +import de.steamwar.sql.Punishment; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.io.IOException; +import java.net.URL; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -33,17 +40,84 @@ import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Date; -import java.util.regex.MatchResult; -import java.util.regex.Matcher; +import java.util.NoSuchElementException; +import java.util.Scanner; +import java.util.UUID; +import java.util.logging.Level; import java.util.regex.Pattern; public class PunishmentCommand { + private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/"; + private static final JsonParser jsonParser = new JsonParser(); + + public static SteamwarUser getOrCreateOfflinePlayer(String name) { + SteamwarUser user = SteamwarUser.get(name); + if (user != null) { + return user; + } + + UUID uuid = getUUIDofOfflinePlayer(name); + if (uuid == null) { + return null; + } + + return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {}); + } + + private static UUID getUUIDofOfflinePlayer(String playerName) { + try { + final URL url = new URL(API_URL + playerName); + String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString(); + return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); + } catch (NoSuchElementException e) { + // ignore, player does not exist + } catch (IOException e) { + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e); + } + return null; + } + + public static boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) { + SteamwarUser user = player.user(); + if (!user.isPunished(punishment)) { + return false; + } + player.system(punishmentMessage(user, punishment)); + return true; + } + + public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) { + user.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma); + + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID()); + if (player != null) { + ChatSender.disconnect(player).system(punishmentMessage(user, Punishment.PunishmentType.Ban)); + for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) { + SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID()); + if (bannedUser.isPunished(Punishment.PunishmentType.Ban) && bannedUser.getPunishment(Punishment.PunishmentType.Ban).getEndTime().before(time)) { + bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma); + } + } + BannedUserIPs.banIP(user.getId(), player.getAddress().getAddress().getHostAddress()); + } + } + + public static Message punishmentMessage(SteamwarUser user, Punishment.PunishmentType punishment) { + Punishment currentPunishment = user.getPunishment(punishment); + if (currentPunishment.isPerma()) { + return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason()); + } else { + return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason()); + } + } + public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) { new SWCommand(command, "bungeecore.ban") { @Register(description = "PUNISHMENT_USAGE") public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) { - if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) { + SteamwarUser punisher = SteamwarUser.get(player.getUniqueId()); + if (punishmentType.isNeedsAdmin() && !punisher.getUserGroup().isAdminGroup()) { return; } @@ -57,7 +131,10 @@ public class PunishmentCommand { boolean isPerma = date.equalsIgnoreCase("perma"); String msg = String.join(" ", message); - target.punish(punishmentType, banTime, msg, SteamwarUser.get(player.getName()).getId(), isPerma); + if(punishmentType == Punishment.PunishmentType.Ban) + ban(target, banTime, msg, punisher, isPerma); + else + target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma); Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg); } }; @@ -68,7 +145,7 @@ public class PunishmentCommand { new SWCommand(antiCommand, "bungeecore.ban") { @Register(description = "PUNISHMENT_USAGE") public void genericCommand(ProxiedPlayer player, String toUnpunish) { - if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) { + if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) { return; } @@ -83,6 +160,8 @@ public class PunishmentCommand { Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName()); target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false); + if(punishmentType == Punishment.PunishmentType.Ban) + BannedUserIPs.unbanIPs(target.getId()); } }; } @@ -95,7 +174,7 @@ public class PunishmentCommand { } protected SteamwarUser unsafeUser(CommandSender sender, String arg){ - SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg); + SteamwarUser target = getOrCreateOfflinePlayer(arg); if(target == null) Message.send("UNKNOWN_PLAYER", sender); return target; diff --git a/src/de/steamwar/bungeecore/commands/RankCommand.java b/src/de/steamwar/bungeecore/commands/RankCommand.java index eca5518..c661009 100644 --- a/src/de/steamwar/bungeecore/commands/RankCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankCommand.java @@ -21,13 +21,12 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserElo; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.Optional; diff --git a/src/de/steamwar/bungeecore/commands/ReplayCommand.java b/src/de/steamwar/bungeecore/commands/ReplayCommand.java index 86aca8f..e318938 100644 --- a/src/de/steamwar/bungeecore/commands/ReplayCommand.java +++ b/src/de/steamwar/bungeecore/commands/ReplayCommand.java @@ -23,10 +23,10 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.inventory.SWStreamInv; -import de.steamwar.bungeecore.sql.Fight; -import de.steamwar.bungeecore.sql.Punishment; +import de.steamwar.sql.Fight; +import de.steamwar.sql.Punishment; import de.steamwar.sql.SchematicType; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -44,12 +44,12 @@ public class ReplayCommand extends SWCommand { @Register public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) { ChatSender sender = ChatSender.of(player); - if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) + if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return; new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - ArenaMode mode = fight.getGameMode(); + ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType()); ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player); String map = mode.getRandomMap(); diff --git a/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java b/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java index 798a58c..d02c53c 100644 --- a/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java +++ b/src/de/steamwar/bungeecore/commands/SetLocaleCommand.java @@ -19,8 +19,10 @@ package de.steamwar.bungeecore.commands; +import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; +import de.steamwar.network.packets.server.LocaleInvalidationPacket; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.Objects; @@ -35,6 +37,7 @@ public class SetLocaleCommand extends SWCommand { public void genericCommand(ProxiedPlayer player) { ChatSender sender = ChatSender.of(player); sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true); + NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId())); sender.system("LOCK_LOCALE_CHANGED"); } } diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index e7ee335..b28eb61 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -23,8 +23,8 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.TeamTeilnahme; import de.steamwar.messages.ChatSender; @@ -314,7 +314,7 @@ public class TeamCommand extends BasicCommand { teamInvitations.get(target.getId()).add(team.getTeamId()); Message.send("TEAM_INVITE_INVITED", player, args[1]); - ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid()); + ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID()); if(p != null) Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName()); } @@ -358,7 +358,7 @@ public class TeamCommand extends BasicCommand { target.setTeam(0); Message.send("TEAM_REMOVE_REMOVED", player); - ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid()); + ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID()); if(p != null) Message.send("TEAM_REMOVE_REMOVED_TARGET", player); } @@ -429,7 +429,7 @@ public class TeamCommand extends BasicCommand { } private String playerName(SteamwarUser user){ - return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName(); + return ProxyServer.getInstance().getPlayer(user.getUUID()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName(); } private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ @@ -616,7 +616,7 @@ public class TeamCommand extends BasicCommand { private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ if(notLeader(player, user, team)) return; - if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) { + if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) { return; } if (args.length < 2) { diff --git a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java index 60e57dc..1f9a491 100644 --- a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.listeners.ChatListener; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.CommandSender; diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java index d7bb956..ac93796 100644 --- a/src/de/steamwar/bungeecore/commands/TpCommand.java +++ b/src/de/steamwar/bungeecore/commands/TpCommand.java @@ -21,8 +21,8 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.sql.BauweltMember; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.bungeecore.util.BauLock; import de.steamwar.bungeecore.util.Chat19; @@ -87,14 +87,14 @@ public class TpCommand extends BasicCommand { Subserver subserver = Subserver.getSubserver(server); if (subserver != null && subserver.getType() == Servertype.ARENA) { - if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) + if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) SubserverSystem.sendPlayer(subserver, player); } else if(subserver instanceof Bauserver) { Bauserver bauserver = (Bauserver) subserver; ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner()); if (checker != null && CheckCommand.isChecking(checker)) { - SteamwarUser steamwarUser = SteamwarUser.get(player); + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); if (steamwarUser.getUserGroup().isCheckSchematics() || CheckCommand.getCheckingSchem(checker).getOwner() == steamwarUser.getId()) { SubserverSystem.sendPlayer(subserver, player); } else { diff --git a/src/de/steamwar/bungeecore/commands/TutorialCommand.java b/src/de/steamwar/bungeecore/commands/TutorialCommand.java index c9dc9d7..57dec80 100644 --- a/src/de/steamwar/bungeecore/commands/TutorialCommand.java +++ b/src/de/steamwar/bungeecore/commands/TutorialCommand.java @@ -24,8 +24,8 @@ import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.inventory.SWStreamInv; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.Tutorial; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.Tutorial; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; diff --git a/src/de/steamwar/bungeecore/commands/TypeMappers.java b/src/de/steamwar/bungeecore/commands/TypeMappers.java index bf882fd..5b5b409 100644 --- a/src/de/steamwar/bungeecore/commands/TypeMappers.java +++ b/src/de/steamwar/bungeecore/commands/TypeMappers.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; -import de.steamwar.bungeecore.sql.Punishment; +import de.steamwar.sql.Punishment; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; @@ -33,7 +33,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; @UtilityClass public class TypeMappers { @@ -48,7 +47,7 @@ public class TypeMappers { private static TypeValidator arenaPlayer() { return (sender, value, messageSender) -> { ChatSender player = ChatSender.of(value); - if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) { + if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) { return false; } diff --git a/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java b/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java index d0755bd..a7d7f72 100644 --- a/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java +++ b/src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.IgnoreSystem; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/commands/VerifyCommand.java b/src/de/steamwar/bungeecore/commands/VerifyCommand.java index 08aee06..4d2cf64 100644 --- a/src/de/steamwar/bungeecore/commands/VerifyCommand.java +++ b/src/de/steamwar/bungeecore/commands/VerifyCommand.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.bot.AuthManager; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.command.SWCommand; import net.dv8tion.jda.api.entities.Member; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 856e99a..581e618 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -22,12 +22,10 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.mods.Utils; -import de.steamwar.bungeecore.sql.*; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import de.steamwar.sql.Team; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.*; import lombok.Getter; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.CommandSender; @@ -89,7 +87,7 @@ public class WhoisCommand extends SWCommand { if (!userGroup.isTeamGroup()) return; if (userGroup.isAdminGroup()) { - Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); + Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUUID().toString()), user.getUUID().toString()); Message.send("WHOIS_ID", player, user.getId()); if (user.getDiscordId() != null) { Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId()); @@ -104,20 +102,20 @@ public class WhoisCommand extends SWCommand { } Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); - if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { - ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid()); + if(BungeeCord.getInstance().getPlayer(user.getUUID()) != null) { + ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID()); Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d)); Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName()); Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion()); } - if (Utils.playerModMap.containsKey(user.getUuid())) { - Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform(); + if (Utils.playerModMap.containsKey(user.getUUID())) { + Mod.Platform modPlatform = Utils.playerModMap.get(user.getUUID()).get(0).getPlatform(); Message.send("WHOIS_PLATFORM", player, modPlatform.toString()); } if (parameterTypes.contains(WhoisParameterTypes.MOD)) { - List activeMods = Utils.playerModMap.get(user.getUuid()); + List activeMods = Utils.playerModMap.get(user.getUUID()); if (activeMods != null && !activeMods.isEmpty()) { Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size()); diff --git a/src/de/steamwar/bungeecore/inventory/SWInventory.java b/src/de/steamwar/bungeecore/inventory/SWInventory.java index dac6be9..637668c 100644 --- a/src/de/steamwar/bungeecore/inventory/SWInventory.java +++ b/src/de/steamwar/bungeecore/inventory/SWInventory.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.inventory; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.server.CloseInventoryPacket; import de.steamwar.network.packets.server.InventoryPacket; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -46,7 +46,7 @@ public class SWInventory { public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) { itemMap = new HashMap<>(); - InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this); + InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer.getUniqueId()).getId(), this); this.player = proxiedPlayer; this.size = size; this.title = title; @@ -114,7 +114,7 @@ public class SWInventory { public void handleClose() { if(processingClick.compareAndSet(false, true)) { - InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this); + InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player.getUniqueId()).getId(), this); if(close != null) close.clicked(null); processingClick.set(false); @@ -122,7 +122,7 @@ public class SWInventory { } public void open() { - InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString())); + InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player.getUniqueId()).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString())); NetworkSender.send(player, inv); } @@ -137,7 +137,7 @@ public class SWInventory { } public static void close(ProxiedPlayer player) { - NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player).getId())); + NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player.getUniqueId()).getId())); } public void setClose(InvCallback close) { diff --git a/src/de/steamwar/bungeecore/listeners/BanListener.java b/src/de/steamwar/bungeecore/listeners/BanListener.java index f5b31bb..51ded5c 100644 --- a/src/de/steamwar/bungeecore/listeners/BanListener.java +++ b/src/de/steamwar/bungeecore/listeners/BanListener.java @@ -21,16 +21,19 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.commands.PunishmentCommand; +import de.steamwar.bungeecore.commands.WebpasswordCommand; import de.steamwar.bungeecore.listeners.mods.Forge; import de.steamwar.sql.BannedUserIPs; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.LoginEvent; import net.md_5.bungee.event.EventHandler; @@ -45,16 +48,17 @@ public class BanListener extends BasicListener { public void onLogin(LoginEvent event) { event.registerIntent(BungeeCore.get()); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { - SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection()); + PendingConnection connection = event.getConnection(); + SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername); if (user.isPunished(Punishment.PunishmentType.Ban)) { - user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress()); event.setCancelled(true); - ChatSender.of(event).system(user.punishmentMessage(Punishment.PunishmentType.Ban)); + BannedUserIPs.banIP(user.getId(), connection.getAddress().getAddress().getHostAddress()); + ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban)); event.completeIntent(BungeeCore.get()); return; } - List ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress()); + List ips = BannedUserIPs.get(connection.getAddress().getAddress().getHostAddress()); if(!ips.isEmpty()){ Timestamp highestBan = ips.get(0).getTimestamp(); diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index dd84a9f..4ac8851 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -21,11 +21,14 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; +import de.steamwar.bungeecore.commands.PunishmentCommand; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.messages.ChatSender; import de.steamwar.network.packets.server.PingPacket; +import de.steamwar.sql.Punishment; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; import de.steamwar.sql.UserGroup; import net.md_5.bungee.api.*; @@ -39,6 +42,7 @@ import net.md_5.bungee.event.EventHandler; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -61,7 +65,9 @@ public class ChatListener extends BasicListener { e.setCancelled(true); if (message.contains("jndi:ldap")) { - SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt."); return; } @@ -155,7 +161,7 @@ public class ChatListener extends BasicListener { return true; } - if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) + if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) return true; if (message.contains("LIXFEL")) @@ -204,7 +210,7 @@ public class ChatListener extends BasicListener { String mark = "@" + player.user().getUserName(); return Arrays.stream(message.split(" ")).map(cur -> { if(cur.equalsIgnoreCase(mark)) { - NetworkSender.send(player.user().getPlayer(), new PingPacket(player.user().getId())); + NetworkSender.send(ProxyServer.getInstance().getPlayer(player.user().getUUID()), new PingPacket(player.user().getId())); return "§e" + cur + returnColor; } return cur; diff --git a/src/de/steamwar/bungeecore/listeners/CheckListener.java b/src/de/steamwar/bungeecore/listeners/CheckListener.java index 0f236d6..e7b1e84 100644 --- a/src/de/steamwar/bungeecore/listeners/CheckListener.java +++ b/src/de/steamwar/bungeecore/listeners/CheckListener.java @@ -23,7 +23,7 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.sql.SchematicNode; import de.steamwar.sql.SchematicType; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PostLoginEvent; diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 33fd29e..ddde4f7 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -30,7 +30,7 @@ import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.commands.ModCommand; import de.steamwar.bungeecore.commands.MsgCommand; import de.steamwar.bungeecore.listeners.mods.Utils; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.ProxyServer; diff --git a/src/de/steamwar/bungeecore/listeners/EventModeListener.java b/src/de/steamwar/bungeecore/listeners/EventModeListener.java index 48d498f..4d2b23f 100644 --- a/src/de/steamwar/bungeecore/listeners/EventModeListener.java +++ b/src/de/steamwar/bungeecore/listeners/EventModeListener.java @@ -1,8 +1,8 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.EventFight; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.EventFight; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.Event; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/de/steamwar/bungeecore/listeners/PollSystem.java b/src/de/steamwar/bungeecore/listeners/PollSystem.java index 69a4fb3..b0bf952 100644 --- a/src/de/steamwar/bungeecore/listeners/PollSystem.java +++ b/src/de/steamwar/bungeecore/listeners/PollSystem.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.Message; import de.steamwar.sql.PollAnswer; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PostLoginEvent; diff --git a/src/de/steamwar/bungeecore/listeners/SessionManager.java b/src/de/steamwar/bungeecore/listeners/SessionManager.java index dcc8d96..db5a820 100644 --- a/src/de/steamwar/bungeecore/listeners/SessionManager.java +++ b/src/de/steamwar/bungeecore/listeners/SessionManager.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.sql.Session; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PostLoginEvent; @@ -43,7 +43,7 @@ public class SessionManager extends BasicListener { public void onDisconnect(PlayerDisconnectEvent e){ Timestamp timestamp = sessions.remove(e.getPlayer()); if(timestamp != null) { - ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp)); + ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp)); } } } diff --git a/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java b/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java index 5affb64..ec11c46 100644 --- a/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java +++ b/src/de/steamwar/bungeecore/listeners/SettingsChangedListener.java @@ -20,7 +20,9 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.network.NetworkSender; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.network.packets.server.LocaleInvalidationPacket; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.SettingsChangedEvent; @@ -32,7 +34,9 @@ public class SettingsChangedListener extends BasicListener { public void onSettingsChanged(SettingsChangedEvent event) { BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { ProxiedPlayer player = event.getPlayer(); - SteamwarUser.get(player).setLocale(player.getLocale(), false); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + user.setLocale(player.getLocale(), false); + NetworkSender.send(player, new LocaleInvalidationPacket(user.getId())); }); } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index c9c9d2a..9bed4e0 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -27,9 +27,9 @@ import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.BasicListener; -import de.steamwar.bungeecore.sql.Mod; +import de.steamwar.sql.Mod; import de.steamwar.sql.SWException; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; @@ -58,7 +58,7 @@ public class Fabric extends BasicListener { continue; } if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) { - logMessage(SteamwarUser.get(entry.getKey()), "Expected message not received", String.valueOf(entry.getValue())); + logMessage(SteamwarUser.get(entry.getKey().getUniqueId()), "Expected message not received", String.valueOf(entry.getValue())); return; } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index d6ebf21..ff5efb9 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; -import de.steamwar.bungeecore.sql.Mod; +import de.steamwar.sql.Mod; import io.netty.channel.ChannelPipeline; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge12.java b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java index 2bdd5a8..02a9082 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge12.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge12.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; -import de.steamwar.bungeecore.sql.Mod; +import de.steamwar.sql.Mod; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import net.md_5.bungee.api.ProxyServer; diff --git a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java index 22887d4..20fcaca 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java +++ b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java @@ -23,7 +23,7 @@ import com.google.gson.JsonObject; import com.google.gson.stream.JsonReader; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; -import de.steamwar.bungeecore.sql.Mod; +import de.steamwar.sql.Mod; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index d4739c6..15e66bb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -21,11 +21,11 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.Mod; -import de.steamwar.bungeecore.sql.Mod.ModType; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.commands.PunishmentCommand; +import de.steamwar.sql.SteamwarUser; import de.steamwar.messages.ChatSender; +import de.steamwar.sql.Mod; +import de.steamwar.sql.Mod.ModType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -97,7 +97,7 @@ public class Utils { } if(max == ModType.RED) { - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false); + PunishmentCommand.ban(user, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, SteamwarUser.get(-1), false); BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt."); } diff --git a/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java index 1b39625..f003098 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java +++ b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java @@ -3,7 +3,7 @@ package de.steamwar.bungeecore.listeners.mods; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import de.steamwar.bungeecore.listeners.BasicListener; -import de.steamwar.bungeecore.sql.Mod; +import de.steamwar.sql.Mod; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; diff --git a/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java b/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java index ae31db5..91f8027 100644 --- a/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java +++ b/src/de/steamwar/bungeecore/network/handlers/ExecuteCommandHandler.java @@ -19,7 +19,7 @@ package de.steamwar.bungeecore.network.handlers; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.ExecuteCommandPacket; import net.md_5.bungee.api.ProxyServer; @@ -31,6 +31,6 @@ public class ExecuteCommandHandler extends PacketHandler { SteamwarUser target = SteamwarUser.get(packet.getPlayerId()); String command = packet.getCommand(); - ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command); + ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUUID()), command); } } diff --git a/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java index d6dc4a0..3487915 100644 --- a/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java +++ b/src/de/steamwar/bungeecore/network/handlers/FightEndsHandler.java @@ -23,7 +23,9 @@ import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.sql.*; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; +import de.steamwar.sql.SchemElo; import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; import lombok.RequiredArgsConstructor; import java.util.*; @@ -91,8 +93,8 @@ public class FightEndsHandler extends PacketHandler { gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers())); } - int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem()); - int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem()); + int blueSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getBlueSchem()); + int redSchemElo = SchemElo.getCurrentElo(fightEndsPacket.getRedSchem()); int blueTeamElo = fightEndsPacket.getBluePlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum(); int redTeamElo = fightEndsPacket.getRedPlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum(); diff --git a/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java b/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java index 03da0f9..b759f8c 100644 --- a/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java +++ b/src/de/steamwar/bungeecore/network/handlers/InventoryCallbackHandler.java @@ -22,15 +22,13 @@ package de.steamwar.bungeecore.network.handlers; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.inventory.InvCallback; import de.steamwar.bungeecore.inventory.SWInventory; -import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.ServerMetaInfo; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.InventoryCallbackPacket; import de.steamwar.network.packets.server.CloseInventoryPacket; import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.config.ServerInfo; import java.util.HashMap; import java.util.Map; @@ -44,7 +42,7 @@ public class InventoryCallbackHandler extends PacketHandler { SteamwarUser owner = SteamwarUser.get(packet.getOwner()); InventoryCallbackPacket.CallbackType type = packet.getType(); if(!inventoryHashMap.containsKey(owner.getId())) { - BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUuid()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden."); + BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUUID()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden."); if(type == InventoryCallbackPacket.CallbackType.CLICK) { NetworkSender.send(((ServerMetaInfo) packet.getMetaInfos()).getSender(), new CloseInventoryPacket(owner.getId())); } diff --git a/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java b/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java index 2f25c44..d9eae09 100644 --- a/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java +++ b/src/de/steamwar/bungeecore/network/handlers/PrepareSchemHandler.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore.network.handlers; import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.ServerStarter; import de.steamwar.sql.SchematicType; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.client.PrepareSchemPacket; import net.md_5.bungee.api.ProxyServer; @@ -32,7 +32,7 @@ public class PrepareSchemHandler extends PacketHandler { @Handler public void handle(PrepareSchemPacket packet) { - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUuid()); + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(packet.getPlayer()).getUUID()); int schematicID = packet.getSchem(); ArenaMode mode = ArenaMode.getBySchemType(SchematicType.fromDB(packet.getSchemType())); diff --git a/src/de/steamwar/bungeecore/sql/CheckedSchematic.java b/src/de/steamwar/bungeecore/sql/CheckedSchematic.java index 77815c4..44a9010 100644 --- a/src/de/steamwar/bungeecore/sql/CheckedSchematic.java +++ b/src/de/steamwar/bungeecore/sql/CheckedSchematic.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.sql; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; import java.sql.ResultSet; diff --git a/src/de/steamwar/bungeecore/sql/EventFight.java b/src/de/steamwar/bungeecore/sql/EventFight.java deleted file mode 100644 index 0a7072e..0000000 --- a/src/de/steamwar/bungeecore/sql/EventFight.java +++ /dev/null @@ -1,150 +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 . -*/ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.internal.Statement; -import de.steamwar.bungeecore.ArenaMode; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.*; - -import static java.time.temporal.ChronoUnit.SECONDS; - -public class EventFight implements Comparable { - - private static final Statement reschedule = new Statement("UPDATE EventFight SET StartTime = ? WHERE EventID = ? AND FightID = ?"); - private static final Statement allComing = new Statement("SELECT * FROM EventFight WHERE StartTime > now() ORDER BY `StartTime` ASC"); - private static final Statement event = new Statement("SELECT * FROM EventFight WHERE EventID = ? ORDER BY `StartTime` ASC"); - - private static final Queue fights = new PriorityQueue<>(); - - private final int eventID; - private final int fightID; - private Timestamp startTime; - private final ArenaMode spielmodus; - private final String map; - private final int teamBlue; - private final int teamRed; - private final int kampfleiter; - private final int ergebnis; - private final int fight; - - private EventFight(ResultSet rs) throws SQLException { - eventID = rs.getInt("EventID"); - fightID = rs.getInt("FightID"); - startTime = rs.getTimestamp("StartTime"); - spielmodus = ArenaMode.getByInternal(rs.getString("Spielmodus")); - map = rs.getString("Map"); - teamBlue = rs.getInt("TeamBlue"); - teamRed = rs.getInt("TeamRed"); - kampfleiter = rs.getInt("Kampfleiter"); - ergebnis = rs.getInt("Ergebnis"); - fight = rs.getInt("Fight"); - } - - public void reschedule(){ - startTime = Timestamp.from(new Date().toInstant().plus(30, SECONDS)); - reschedule.update(startTime, eventID, fightID); - } - - public static void loadAllComingFights(){ - allComing.select(rs -> { - fights.clear(); - while(rs.next()){ - fights.add(new EventFight(rs)); - } - return null; - }); - } - - public static List getEvent(int eventID){ - return event.select(rs -> { - List fights = new LinkedList<>(); - while(rs.next()) - fights.add(new EventFight(rs)); - return fights; - }, eventID); - } - - public static Queue getFights() { - return fights; - } - - public Timestamp getStartTime() { - return startTime; - } - - public ArenaMode getSpielmodus() { - return spielmodus; - } - - public String getMap() { - return map; - } - - public int getTeamBlue() { - return teamBlue; - } - - public int getTeamRed() { - return teamRed; - } - - public int getEventID() { - return eventID; - } - - public int getFightID() { - return fightID; - } - - public int getKampfleiter() { - return kampfleiter; - } - - public int getErgebnis() { - return ergebnis; - } - - public boolean hasFinished() { - return fight != 0; - } - - @Override - public int hashCode(){ - return fightID; - } - - @Override - public boolean equals(Object o){ - if(o == null) - return false; - if(!(o instanceof EventFight)) - return false; - return fightID == ((EventFight) o).fightID; - } - - @Override - public int compareTo(EventFight o) { - return startTime.compareTo(o.startTime); - } -} diff --git a/src/de/steamwar/bungeecore/sql/Fight.java b/src/de/steamwar/bungeecore/sql/Fight.java deleted file mode 100644 index 7de3de0..0000000 --- a/src/de/steamwar/bungeecore/sql/Fight.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2023 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 . - */ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.FightPlayer; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.internal.Statement; -import de.steamwar.bungeecore.ArenaMode; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class Fight { - - private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win, (SELECT COUNT(1) FROM Replay WHERE Replay.FightID = f.FightID) as ReplayAvailable FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?"); - - private final int fightID; - private final String gameMode; - private final String server; - private final Timestamp startTime; - - private final int blueLeader; - private final int redLeader; - private final int win; - - private final boolean replayAllowed; - private final boolean replayAvailable; - - private final List bluePlayers = new ArrayList<>(); - private final List redPlayers = new ArrayList<>(); - - private Fight(ResultSet rs) throws SQLException { - fightID = rs.getInt("FightID"); - gameMode = rs.getString("GameMode"); - server = rs.getString("Server"); - startTime = rs.getTimestamp("StartTime"); - blueLeader = rs.getInt("BlueLeader"); - redLeader = rs.getInt("RedLeader"); - replayAllowed = rs.getBoolean("ReplayAllowed"); - replayAvailable = rs.getBoolean("ReplayAvailable"); - win = rs.getInt("Win"); - } - - private void initPlayers(List fightPlayers) { - for(FightPlayer fp : fightPlayers) { - if(fp.getFightID() != fightID) - continue; - - if(fp.getTeam() == 1) - bluePlayers.add(fp); - else - redPlayers.add(fp); - } - } - - public static List getPage(int page, int elementsPerPage) { - List fights = getPage.select(rs -> { - List f = new ArrayList<>(); - while(rs.next()){ - f.add(new Fight(rs)); - } - return f; - }, page * elementsPerPage, elementsPerPage); - - List fightPlayers = FightPlayer.batchGet(fights.stream().map(f -> f.fightID).toArray(Integer[]::new)); - for(Fight fight : fights) { - fight.initPlayers(fightPlayers); - } - - de.steamwar.bungeecore.sql.SteamwarUser.batchCache(fightPlayers.stream().map(FightPlayer::getUserID).collect(Collectors.toSet())); - return fights; - } - - public SchematicType getSchemType() { - return SchematicType.fromDB(gameMode); - } - - public ArenaMode getGameMode() { - SchematicType schemType = getSchemType(); - if(schemType == null) - return null; - return ArenaMode.getBySchemType(schemType); - } - - public int getFightID() { - return fightID; - } - - public Timestamp getStartTime() { - return startTime; - } - - public de.steamwar.bungeecore.sql.SteamwarUser getBlueLeader() { - return de.steamwar.bungeecore.sql.SteamwarUser.get(blueLeader); - } - - public de.steamwar.bungeecore.sql.SteamwarUser getRedLeader() { - return SteamwarUser.get(redLeader); - } - - public int getWin() { - return win; - } - - public String getServer() { - return server; - } - - public List getBluePlayers() { - return bluePlayers; - } - - public List getRedPlayers() { - return redPlayers; - } - - public boolean replayAllowed() { - return replayExists() && replayAllowed; - } - - public boolean replayExists() { - return getGameMode() != null && replayAvailable; - } -} diff --git a/src/de/steamwar/bungeecore/sql/IgnoreSystem.java b/src/de/steamwar/bungeecore/sql/IgnoreSystem.java index b152805..9631f5a 100644 --- a/src/de/steamwar/bungeecore/sql/IgnoreSystem.java +++ b/src/de/steamwar/bungeecore/sql/IgnoreSystem.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.sql; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java deleted file mode 100644 index 897b7f9..0000000 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ /dev/null @@ -1,127 +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 . -*/ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.internal.Statement; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public class Mod { - - private static final Statement get = new Statement("SELECT * FROM Mods WHERE ModName = ? AND Platform = ?"); - private static final Statement insert = new Statement("INSERT INTO Mods (ModName, Platform) VALUES (?, ?)"); - - private static final Statement set = new Statement("UPDATE Mods Set ModType = ? WHERE ModName = ? AND Platform = ?"); - private static final Statement findFirst = new Statement("SELECT * FROM Mods WHERE ModType = 0 LIMIT 1"); - - private static final Statement getPageOfType = new Statement("SELECT * FROM Mods WHERE ModType = ? ORDER BY ModName DESC LIMIT ?, ?"); - - private final String modName; - private final Platform platform; - private final ModType modType; - - private Mod(String modName, Platform platform, ModType modType) { - this.modName = modName; - this.platform = platform; - this.modType = modType; - } - - private Mod(ResultSet resultSet) throws SQLException { - this(resultSet.getString("ModName"), Mod.Platform.values()[resultSet.getInt("Platform")], ModType.values()[resultSet.getInt("ModType")]); - } - - public static Mod get(String name, Platform platform) { - return get.select(rs -> { - if(rs.next()) - return new Mod(rs); - return null; - }, name, platform.ordinal()); - } - - public static Mod getOrCreate(String name, Platform platform) { - Mod mod = get(name, platform); - if(mod != null) - return mod; - - insert.update(name, platform.ordinal()); - return new Mod(name, platform, ModType.UNKLASSIFIED); - } - - public void setModType(Mod.ModType newModType) { - set.update(newModType.ordinal(), modName, platform.ordinal()); - } - - public static List getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) { - return Mod.getPageOfType.select(rs -> { - List f = new ArrayList<>(); - - while(rs.next()) - f.add(new Mod(rs)); - - return f; - },filter.ordinal(), page * elementsPerPage, elementsPerPage); - } - - public static Mod findFirstMod() { - return findFirst.select(rs -> { - if(rs.next()) - return new Mod(rs); - return null; - }); - } - - public String getModName() { - return modName; - } - - public Platform getPlatform() { - return platform; - } - - public ModType getModType() { - return modType; - } - - public enum Platform{ - FORGE, - LABYMOD, - FABRIC - } - - public enum ModType { - UNKLASSIFIED("7"), - GREEN("a"), - YELLOW("e"), - RED("c"), - YOUTUBER_ONLY("6"); - - ModType(String colorcode) { - this.colorcode = colorcode; - } - private final String colorcode; - - public String getColorCode() { - return colorcode; - } - } -} diff --git a/src/de/steamwar/bungeecore/sql/NodeMember.java b/src/de/steamwar/bungeecore/sql/NodeMember.java deleted file mode 100644 index 878982c..0000000 --- a/src/de/steamwar/bungeecore/sql/NodeMember.java +++ /dev/null @@ -1,86 +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 . - */ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.internal.Statement; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; - -public class NodeMember { - private static final Statement getNodeMember = new Statement("SELECT * FROM NodeMember WHERE NodeId = ? AND UserId = ?"); - private static final Statement getNodeMembers = new Statement("SELECT * FROM NodeMember WHERE NodeId = ?"); - private static final Statement getSchematics = new Statement("SELECT * FROM NodeMember WHERE UserId = ?"); - private static final Statement createNodeMember = new Statement("INSERT INTO NodeMember (NodeId, UserId) VALUES (?, ?)"); - private static final Statement deleteNodeMember = new Statement("DELETE FROM NodeMember WHERE NodeId = ? AND UserId = ?"); - - public static NodeMember getNodeMember(int node, int member) { - return getNodeMember.select(rs -> { - if(!rs.next()) - return null; - return new NodeMember(rs); - }, node, member); - } - - public static Set getNodeMembers(int node) { - return getNodeMembers.select(rs -> { - Set members = new HashSet<>(); - while (rs.next()) - members.add(new NodeMember(rs)); - return members; - }, node); - } - - public static Set getSchematics(int member) { - return getSchematics.select(rs -> { - Set members = new HashSet<>(); - while (rs.next()) - members.add(new NodeMember(rs)); - return members; - }, member); - } - - public static NodeMember createNodeMember(int node, int member) { - createNodeMember.update(node, member); - return getNodeMember(node, member); - } - - final int node; - final int member; - - private NodeMember(ResultSet set) throws SQLException { - node = set.getInt("NodeId"); - member = set.getInt("UserId"); - } - - public int getNode() { - return node; - } - - public int getMember() { - return member; - } - - public void delete() { - deleteNodeMember.update(node, member); - } -} diff --git a/src/de/steamwar/bungeecore/sql/Punishment.java b/src/de/steamwar/bungeecore/sql/Punishment.java deleted file mode 100644 index 8bc3b4a..0000000 --- a/src/de/steamwar/bungeecore/sql/Punishment.java +++ /dev/null @@ -1,160 +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 . - */ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.internal.Statement; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.time.Instant; -import java.time.format.DateTimeFormatter; -import java.util.*; - -public class Punishment { - - private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1"); - private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)"); - private static final Statement getAllPunishments = new Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC"); - private static final Statement insert = new Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)"); - - public static final Timestamp PERMA_TIME = Timestamp.from(Instant.ofEpochSecond(946674800)); - - public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) { - return getPunishment.select(rs -> { - if (rs.next()) - return new Punishment(rs); - return null; - }, user, type.name()); - } - - public static Map getPunishmentsOfPlayer(int user) { - return getPunishments.select(rs -> { - Map punishments = new HashMap<>(); - while (rs.next()) - punishments.put(PunishmentType.valueOf(rs.getString("Type")), new Punishment(rs)); - return punishments; - }, user); - } - - public static List getAllPunishmentsOfPlayer(int user) { - return getAllPunishments.select(rs -> { - List punishments = new ArrayList<>(); - while (rs.next()) - punishments.add(new Punishment(rs)); - return punishments; - }, user); - } - - public static Punishment createPunishment(int user, int executor, PunishmentType type, String reason, Timestamp endTime, boolean perma) { - if(perma && !endTime.equals(PERMA_TIME)) { - throw new IllegalArgumentException("Permanent punishments must have an end time of `Punishment.PERMA_TIME`"); - } - insert.update(user, executor, type.name(), reason, endTime, perma); - return getPunishmentOfPlayer(user, type); - } - - private final Timestamp startTime; - private Timestamp endTime; - private final PunishmentType type; - private final int user; - private final int id; - private String reason; - private final int punisher; - private boolean perma; - - private Punishment(ResultSet set) throws SQLException { - user = set.getInt("UserId"); - reason = set.getString("Reason"); - type = PunishmentType.valueOf(set.getString("Type")); - startTime = set.getTimestamp("StartTime"); - endTime = set.getTimestamp("EndTime"); - punisher = set.getInt("Punisher"); - perma = set.getBoolean("Perma"); - id = set.getInt("PunishmentId"); - } - - public Timestamp getStartTime() { - return startTime; - } - - public Timestamp getEndTime() { - return endTime; - } - - public PunishmentType getType() { - return type; - } - - public int getUser() { - return user; - } - - public String getReason() { - return reason; - } - - public int getPunisher() { - return punisher; - } - - public boolean isPerma() { - return perma; - } - - public String getBantime(Timestamp endTime, boolean perma) { - if (perma) { - return "permanent"; - } else { - return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")); - } - } - - public boolean isCurrent() { - return isPerma() || getEndTime().after(new Date()); - } - - @AllArgsConstructor - @RequiredArgsConstructor - @Getter - public enum PunishmentType { - Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"), - Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"), - NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"), - NoSchemSharing(false, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"), - NoSchemSubmitting(true, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"), - NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"), - NoFightServer(false, "NOFIGHTSERVER_TEAM", "NOFIGHTSERVER_PERMA", "NOFIGHTSERVER_UNTIL", "UNNOFIGHTSERVER_ERROR", "UNNOFIGHTSERVER"), - NoTeamServer(true, "NOTEAMSERVER_TEAM", "NOTEAMSERVER_PERMA", "NOTEAMSERVER_UNTIL", "UNNOTEAMSERVER_ERROR", "UNNOTEAMSERVER"), - Note(false, "NOTE_TEAM", null, null, null, null, true), - ; - - private final boolean needsAdmin; - private final String teamMessage; - private final String playerMessagePerma; - private final String playerMessageUntil; - private final String usageNotPunished; - private final String unpunishmentMessage; - private boolean multi = false; - } -} diff --git a/src/de/steamwar/bungeecore/sql/SchemElo.java b/src/de/steamwar/bungeecore/sql/SchemElo.java deleted file mode 100644 index 8f58e13..0000000 --- a/src/de/steamwar/bungeecore/sql/SchemElo.java +++ /dev/null @@ -1,52 +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 . - */ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.Season; -import de.steamwar.sql.internal.Statement; - -import static de.steamwar.bungeecore.sql.UserElo.ELO_DEFAULT; - -public class SchemElo { - private SchemElo() {} - - private static final Statement elo = new Statement("SELECT Elo FROM SchemElo WHERE SchemID = ? AND Season = ?"); - private static final Statement setElo = new Statement("INSERT INTO SchemElo (Season, SchemID, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)"); - - public static int getElo(int schemID) { - return getElo(Season.getSeason(), schemID); - } - - public static int getElo(int season, int schemID) { - return elo.select(rs -> { - if (rs.next()) - return rs.getInt("Elo"); - return ELO_DEFAULT; - }, schemID, season); - } - - public static void setElo(int schemID, int elo) { - setElo(Season.getSeason(), schemID, elo); - } - - public static void setElo(int season, int schemID, int elo) { - setElo.update(season, schemID, elo); - } -} diff --git a/src/de/steamwar/bungeecore/sql/SchematicNode.java b/src/de/steamwar/bungeecore/sql/SchematicNode.java index 9c91c02..e8bca5b 100644 --- a/src/de/steamwar/bungeecore/sql/SchematicNode.java +++ b/src/de/steamwar/bungeecore/sql/SchematicNode.java @@ -20,7 +20,9 @@ package de.steamwar.bungeecore.sql; +import de.steamwar.sql.NodeMember; import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; import java.io.InputStream; diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java deleted file mode 100644 index f42f53e..0000000 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ /dev/null @@ -1,398 +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 . -*/ - -package de.steamwar.bungeecore.sql; - -import com.google.gson.JsonParser; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.commands.WebpasswordCommand; -import de.steamwar.bungeecore.listeners.ConnectionListener; -import de.steamwar.bungeecore.network.NetworkSender; -import de.steamwar.messages.ChatSender; -import de.steamwar.network.packets.server.LocaleInvalidationPacket; -import de.steamwar.sql.BannedUserIPs; -import de.steamwar.sql.UserGroup; -import de.steamwar.sql.internal.Statement; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.PendingConnection; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.URL; -import java.net.UnknownHostException; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.*; -import java.util.logging.Level; -import java.util.stream.Collectors; - - -public class SteamwarUser { - - private static final Statement updateName = new Statement("UPDATE UserData SET UserName = ? WHERE id = ?"); - private static final Statement updateBedrock = new Statement("UPDATE UserData SET Bedrock = ? WHERE id = ?"); - private static final Statement updateLocale = new Statement("UPDATE UserData SET Locale = ?, ManualLocale = ? WHERE id = ?"); - private static final Statement insert = new Statement("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, 'Member')"); - private static final Statement byUUID = new Statement("SELECT * FROM UserData WHERE UUID = ?"); - private static final Statement byName = new Statement("SELECT * FROM UserData WHERE lower(UserName) = ?"); - private static final Statement byID = new Statement("SELECT * FROM UserData WHERE id = ?"); - private static final Statement byDiscord = new Statement("SELECT * FROM UserData WHERE DiscordId = ?"); - private static final Statement updateTeam = new Statement("Update UserData SET Team = ? WHERE id = ?"); - private static final Statement updateDiscord = new Statement("Update UserData SET DiscordId = ? WHERE id = ?"); - private static final Statement deleteIPs = new Statement("DELETE FROM BannedUserIPs WHERE UserID = ?"); - private static final Statement updateLeader = new Statement("Update UserData SET Leader = ? WHERE id = ?"); - private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?"); - private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?"); - - private static final Map usersByName = new HashMap<>(); - private static final Map usersByUUID = new HashMap<>(); - private static final Map usersById = new HashMap<>(); - private static final Map usersByDiscord = new HashMap<>(); - private static final InetAddress LIXFEL_DE; - private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/"; - private static final JsonParser jsonParser = new JsonParser(); - - private final int id; - private final UUID uuid; - private String userName; - private final UserGroup userGroup; - private int team; - private boolean leader; - private final Map punishments; - private Long discordId; - - private Locale locale; - private boolean manualLocale; - - static { - try { - LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43}); - } catch (UnknownHostException e) { - ProxyServer.getInstance().stop(); - throw new SecurityException("Could not initialise address!", e); - } - } - - private SteamwarUser(ResultSet rs) throws SQLException { - id = rs.getInt("id"); - uuid = UUID.fromString(rs.getString("UUID")); - userName = rs.getString("UserName"); - userGroup = UserGroup.getUsergroup(rs.getString("UserGroup")); - team = rs.getInt("Team"); - leader = rs.getBoolean("Leader"); - discordId = rs.getLong("DiscordId"); - if(rs.wasNull()) { - discordId = null; - } - - String dbLocale = rs.getString("Locale"); - locale = dbLocale != null ? Locale.forLanguageTag(dbLocale) : null; - manualLocale = rs.getBoolean("ManualLocale"); - - usersById.put(id, this); - usersByName.put(userName.toLowerCase(), this); - usersByUUID.put(uuid, this); - if (discordId != null) { - usersByDiscord.put(discordId, this); - } - punishments = Punishment.getPunishmentsOfPlayer(id); - } - - public static SteamwarUser getOrCreate(PendingConnection connection) { - SteamwarUser user = SteamwarUser.get(connection.getUniqueId()); - - if (user != null) { - String userName = connection.getName(); - if (!user.userName.equals(userName)) { - updateName.update(userName, user.id); - WebpasswordCommand.changeUsername(user.userName, userName); - user.userName = userName; - } - } else { - user = SteamwarUser.createUserInDatabase(connection.getUniqueId(), connection.getName()); - if (user == null) { - throw new SecurityException("user == null"); - } - ConnectionListener.newPlayer(user.uuid); - } - - boolean bedrock = connection.getAddress().getAddress().equals(LIXFEL_DE); - updateBedrock.update(bedrock, user.id); - return user; - } - - public static SteamwarUser getOrCreateOfflinePlayer(String name) { - SteamwarUser user = SteamwarUser.get(name); - if (user != null) { - return user; - } - - UUID uuid = SteamwarUser.getUUIDofOfflinePlayer(name); - if (uuid == null) { - return null; - } - - user = SteamwarUser.get(uuid); - if (user != null) { - return user; - } - - return SteamwarUser.createUserInDatabase(uuid, name); - } - - private static SteamwarUser createUserInDatabase(UUID uuid, String name) { - insert.update(uuid.toString(), name); - return get(uuid); - } - - public static SteamwarUser get(String userName) { - userName = userName.toLowerCase(); - if (usersByName.containsKey(userName)) { - return usersByName.get(userName); - } - return byName.select(rs -> { - if (rs.next()) - return new SteamwarUser(rs); - return null; - }, userName); - } - - public static SteamwarUser get(UUID uuid) { - if (usersByUUID.containsKey(uuid)) { - return usersByUUID.get(uuid); - } - return byUUID.select(rs -> { - if (rs.next()) - return new SteamwarUser(rs); - return null; - }, uuid.toString()); - } - - public static SteamwarUser get(ProxiedPlayer player) { - return get(player.getUniqueId()); - } - - public static SteamwarUser get(int id) { - if (usersById.containsKey(id)) { - return usersById.get(id); - } - return byID.select(rs -> { - rs.next(); - return new SteamwarUser(rs); - }, id); - } - - public static void batchCache(Set ids) { - ids.removeIf(usersById::containsKey); - if(ids.isEmpty()) - return; - - try (Statement batch = new Statement("SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) { - batch.select(rs -> { - while (rs.next()) - new SteamwarUser(rs); - return null; - }); - } - } - - public static SteamwarUser get(Long discordId) { - if(usersByDiscord.containsKey(discordId)) - return usersByDiscord.get(discordId); - return byDiscord.select(rs -> { - if (rs.next()) - return new SteamwarUser(rs); - return null; - }, discordId); - } - - public static void clearCache() { - usersById.clear(); - usersByName.clear(); - usersByUUID.clear(); - usersByDiscord.clear(); - } - - private static UUID getUUIDofOfflinePlayer(String playerName) { - try { - final URL url = new URL(API_URL + playerName); - String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString(); - return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); - } catch (NoSuchElementException e) { - // ignore, player does not exist - } catch (IOException e) { - BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e); - } - return null; - } - - public void setTeam(int team) { - this.team = team; - updateTeam.update(team, id); - setLeader(false); - } - - public int getId() { - return id; - } - - public UUID getUuid() { - return uuid; - } - - public String getUserName() { - return userName; - } - - public UserGroup getUserGroup() { - return userGroup; - } - - public int getTeam() { - return team; - } - - @Deprecated - public ProxiedPlayer getPlayer() { - return ProxyServer.getInstance().getPlayer(uuid); - } - - public Punishment getPunishment(Punishment.PunishmentType type) { - return punishments.getOrDefault(type, null); - } - - public Long getDiscordId() { - return discordId; - } - - public void setDiscordId(Long discordId) { - usersByDiscord.remove(this.discordId); - this.discordId = discordId; - updateDiscord.update(discordId, id); - if (discordId != null) { - usersByDiscord.put(discordId, this); - } - } - - public boolean isPunished(Punishment.PunishmentType punishment) { - if (!punishments.containsKey(punishment)) { - return false; - } - if (!punishments.get(punishment).isCurrent()) { - if (punishment == Punishment.PunishmentType.Ban) { - deleteIPs.update(id); - } - punishments.remove(punishment); - return false; - } - return true; - } - - public boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) { - if (!isPunished(punishment)) { - return false; - } - player.system(punishmentMessage(punishment)); - return true; - } - - public void punishPerma(Punishment.PunishmentType type, String reason, int from) { - punish(type, Punishment.PERMA_TIME, reason, from, true); - } - - public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) { - punishments.remove(punishment); - punishments.put(punishment, Punishment.createPunishment(id, from, punishment, banReason, time, perma)); - - if (punishment != Punishment.PunishmentType.Ban) { - return; - } - - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid); - if (player != null) { - ChatSender.disconnect(player).system(punishmentMessage(punishment)); - for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) { - SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID()); - if (bannedUser.isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) { - bannedUser.punish(punishment, time, banReason, from, perma); - } - } - updateBanIP(player.getAddress().getAddress().getHostAddress()); - } else { - updateBanIP(""); - } - } - - public Message punishmentMessage(Punishment.PunishmentType punishment) { - Punishment currentPunishment = punishments.get(punishment); - if (currentPunishment.isPerma()) { - return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason()); - } else { - return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason()); - } - } - - public void updateBanIP(String ip) { - BannedUserIPs.banIP(id, ip); - } - - public double getOnlinetime() { - return getPlaytime.select(rs -> { - if (rs.next() && rs.getBigDecimal("Playtime") != null) - return rs.getBigDecimal("Playtime").doubleValue(); - return 0.0; - }, id); - } - - public Timestamp getFirstjoin() { - return getFirstjoin.select(rs -> { - if (rs.next()) - return rs.getTimestamp("FirstJoin"); - return null; - }, id); - } - - public boolean isLeader() { - return leader; - } - - public void setLeader(boolean leader) { - this.leader = leader; - updateLeader.update(leader, id); - } - - public Locale getLocale() { - if (locale != null) - return locale; - return Locale.getDefault(); - } - - public void setLocale(Locale locale, boolean manualLocale) { - if (locale == null || (this.manualLocale && !manualLocale)) - return; - - this.locale = locale; - this.manualLocale = manualLocale; - updateLocale.update(locale.toLanguageTag(), manualLocale, id); - NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id)); - } -} diff --git a/src/de/steamwar/bungeecore/sql/Tutorial.java b/src/de/steamwar/bungeecore/sql/Tutorial.java deleted file mode 100644 index b28b0cd..0000000 --- a/src/de/steamwar/bungeecore/sql/Tutorial.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 . - */ - -package de.steamwar.bungeecore.sql; - -import de.steamwar.sql.internal.Field; -import de.steamwar.sql.internal.Statement; -import de.steamwar.sql.internal.Table; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -@AllArgsConstructor -public class Tutorial { - - private static final Table table = new Table<>(Tutorial.class); - private static final Statement release = table.update(Table.PRIMARY, "released"); - private static final Statement delete = table.delete(Table.PRIMARY); - - private static final Statement by_popularity = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Released = ? GROUP BY t.TutorialID ORDER BY SUM(r.Stars) DESC LIMIT ?, ?"); - private static final Statement own = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? GROUP BY t.TutorialID ORDER BY t.TutorialID ASC LIMIT ?, ?"); - private static final Statement by_creator_name = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.Creator = ? AND t.Name = ? GROUP BY t.TutorialID"); - private static final Statement by_id = new Statement("SELECT t.*, AVG(r.Stars) AS Stars FROM Tutorial t LEFT OUTER JOIN TutorialRating r ON t.TutorialID = r.TutorialID WHERE t.TutorialID = ? GROUP BY t.TutorialID"); - private static final Statement rate = new Statement("INSERT INTO TutorialRating (TutorialID, UserID, Stars) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Stars = VALUES(Stars)"); - private static final Statement create = new Statement("INSERT INTO Tutorial (Creator, Name, Item) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), Released = 0"); - - public static List getPage(int page, int elementsPerPage, boolean released) { - List tutorials = by_popularity.select(rs -> { - List t = new ArrayList<>(); - while(rs.next()) - t.add(new Tutorial(rs)); - return t; - }, released, page * elementsPerPage, elementsPerPage); - - SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet())); - return tutorials; - } - - public static List getOwn(int user, int page, int elementsPerPage) { - return own.select(rs -> { - List t = new ArrayList<>(); - while(rs.next()) - t.add(new Tutorial(rs)); - return t; - }, user, page * elementsPerPage, elementsPerPage); - } - - public static Tutorial create(int creator, String name, String item) { - create.update(creator, name, item); - return by_creator_name.select(rs -> { - rs.next(); - return new Tutorial(rs); - }, creator, name); - } - - public static Tutorial get(int id) { - return by_id.select(rs -> { - if(rs.next()) - return new Tutorial(rs); - return null; - }, id); - } - - @Getter - @Field(keys = {Table.PRIMARY}, autoincrement = true) - private final int id; - @Getter - @Field(keys = {"CreatorName"}) - private final int creator; - @Getter - @Field(keys = {"CreatorName"}) - private final String name; - @Getter - @Field(def = "'BOOK'") - private final String item; - @Getter - @Field(def = "0") - private final boolean released; - @Getter - private final double stars; - - public Tutorial(ResultSet rs) throws SQLException { - this.id = rs.getInt("TutorialID"); - this.creator = rs.getInt("Creator"); - this.name = rs.getString("Name"); - this.item = rs.getString("Item"); - this.released = rs.getBoolean("Released"); - this.stars = rs.getDouble("Stars"); - } - - public void release() { - release.update(id); - } - - public void delete() { - delete.update(id); - } - - public void rate(int user, int rating) { - rate.update(id, user, rating); - } -} diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java index 3b26c30..ba708cb 100644 --- a/src/de/steamwar/bungeecore/sql/UserElo.java +++ b/src/de/steamwar/bungeecore/sql/UserElo.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.sql; import de.steamwar.bungeecore.ArenaMode; import de.steamwar.bungeecore.Message; import de.steamwar.sql.Season; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.internal.Statement; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/bungeecore/tablist/TablistPart.java b/src/de/steamwar/bungeecore/tablist/TablistPart.java index 151c320..061ae92 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistPart.java +++ b/src/de/steamwar/bungeecore/tablist/TablistPart.java @@ -19,7 +19,7 @@ package de.steamwar.bungeecore.tablist; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.chat.TextComponent; diff --git a/src/de/steamwar/bungeecore/tablist/TablistServer.java b/src/de/steamwar/bungeecore/tablist/TablistServer.java index 5480940..812588d 100644 --- a/src/de/steamwar/bungeecore/tablist/TablistServer.java +++ b/src/de/steamwar/bungeecore/tablist/TablistServer.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.tablist; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.messages.ChatSender; import de.steamwar.network.packets.common.FightInfoPacket; import net.md_5.bungee.BungeeCord; @@ -82,7 +82,7 @@ public class TablistServer implements TablistPart { private void addPlayers(String prefix, List teamPlayers, Collection onlinePlayers){ teamPlayers.stream().map(SteamwarUser::get).map( - user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUuid())).findAny() + user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUUID())).findAny() ).filter(Optional::isPresent).map(Optional::get).sorted( (p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()) ).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player)))); diff --git a/src/de/steamwar/bungeecore/util/BauLock.java b/src/de/steamwar/bungeecore/util/BauLock.java index 2eb4c38..43926dd 100644 --- a/src/de/steamwar/bungeecore/util/BauLock.java +++ b/src/de/steamwar/bungeecore/util/BauLock.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.util; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserConfig; import lombok.experimental.UtilityClass; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -32,7 +32,7 @@ public class BauLock { public static void setLocked(ProxiedPlayer p, BauLockState state) { SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); UserConfig.updatePlayerConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); - Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); + Message.send("BAU_LOCKED_" + state.name(), p); } public static boolean isLocked(SteamwarUser owner, SteamwarUser target) { diff --git a/src/de/steamwar/command/TypeUtils.java b/src/de/steamwar/command/TypeUtils.java index 833cd4b..b83cb96 100644 --- a/src/de/steamwar/command/TypeUtils.java +++ b/src/de/steamwar/command/TypeUtils.java @@ -20,7 +20,7 @@ package de.steamwar.command; import de.steamwar.bungeecore.commands.TypeMappers; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import lombok.experimental.UtilityClass; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/de/steamwar/messages/ChatSender.java b/src/de/steamwar/messages/ChatSender.java index 5b79204..65834f6 100644 --- a/src/de/steamwar/messages/ChatSender.java +++ b/src/de/steamwar/messages/ChatSender.java @@ -21,7 +21,7 @@ package de.steamwar.messages; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.listeners.DiscordChatListener; -import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer;