From 1bec6c4cd46d11777d01eaf0d54239a24532eb01 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 4 Jan 2023 12:00:27 +0100 Subject: [PATCH] Push initial implementation --- src/de/steamwar/bungeecore/BungeeCore.java | 2 + .../bungeecore/commands/ModCommand.java | 60 +++++++++++++++++++ .../bungeecore/commands/WhoisCommand.java | 2 - .../steamwar/messages/BungeeCore.properties | 10 +++- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/bungeecore/commands/ModCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index d07ce13..4f4f10b 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -163,6 +163,8 @@ public class BungeeCore extends Plugin { new CalendarCommand(); new CalendarListener(); + new ModCommand(); + // Punishment Commands: new PunishmentCommand("ban", Punishment.PunishmentType.Ban); new PunishmentCommand("mute", Punishment.PunishmentType.Mute); diff --git a/src/de/steamwar/bungeecore/commands/ModCommand.java b/src/de/steamwar/bungeecore/commands/ModCommand.java new file mode 100644 index 0000000..29a788d --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/ModCommand.java @@ -0,0 +1,60 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.sql.Statement; +import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.sql.UserGroup; +import de.steamwar.command.SWCommand; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class ModCommand extends SWCommand { + + private static final Statement set = new Statement("UPDATE Mods Set ModType = ? WHERE ModName = ?"); + private static final Statement findFirst = new Statement("SELECT * FROM Mods WHERE modType = 0 LIMIT 1"); + + private static final Statement exists = new Statement("SELECT * FROM Mods WHERE ModName = ?"); + + public ModCommand() { + super("mod", "bungeecore.teamchat", "mods"); + } + + @Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE") + public void set(ProxiedPlayer p,String modName,Integer newModType) { + SteamwarUser user = SteamwarUser.get(p.getUniqueId()); + UserGroup group = user.getUserGroup(); + + if(!group.isAdminGroup()) { + Message.send("MOD_COMMAND_SET_USAGE",p); + return; + } + + set.update(newModType,modName); + + Message.send("MOD_CHANGED_TYPE",p,modName,newModType); + } + + @Register(value = {"next"},description = "MOD_COMMAND_NEXT_USAGE") + public void next(ProxiedPlayer p) { + SteamwarUser user = SteamwarUser.get(p.getUniqueId()); + UserGroup group = user.getUserGroup(); + + if(!group.isAdminGroup()) { + Message.send("MOD_COMMAND_NEXT_USAGE",p); + return; + } + + String foundMod = findFirst.select(rs -> { + if(rs.next()) { + return rs.getString("ModName"); + } + return null; + }); + + if(foundMod == null) { + Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p); + return; + } + + Message.send("MOD_FOUND_NEXT_MOD",p,foundMod); + } +} diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index bf016c3..3559249 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -28,11 +28,9 @@ 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.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; -import java.net.InetSocketAddress; import java.sql.Timestamp; import java.text.DecimalFormat; import java.time.Instant; diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 314f26d..3636dac 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -655,4 +655,12 @@ ADVENT_CALENDAR_TITLE=§eAdvent Calendar ADVENT_CALENDAR_DAY=§7Day§8: §e{0} ADVENT_CALENDAR_MESSAGE=§eDid you already open your advent calendar? ADVENT_CALENDAR_MESSAGE_HOVER=§eClick to open! -ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! \ No newline at end of file +ADVENT_CALENDAR_OPEN=§7You got §e{0} §7from the advent calendar! + +#Mod Command +MOD_COMMAND_SET_USAGE=§7/mod [mod name] [ModType 1-4] +MOD_COMMAND_NEXT_USAGE=§7/mod next +MOD_CHANGED_TYPE=§7Successfully reclassified mod {0} to type {1}! +MOD_NO_MORE_UNCLASSIFIED_MODS=§7No more unclassified mods found in databank! +MOD_FOUND_NEXT_MOD=§7Next unclassified mod is {0}! +MOD_COMMAND_NOT_FOUND_IN_DATABASE=§7The Mod {0} was§c not §7found in the database! \ No newline at end of file