From dc234b2b33b9f01c18dffa3008495a6cdb7b8bad Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 4 Jan 2023 20:31:31 +0100 Subject: [PATCH] Push fixes --- .../bungeecore/commands/ModCommand.java | 42 ++++++------------- src/de/steamwar/bungeecore/sql/Mod.java | 11 +++++ .../steamwar/messages/BungeeCore.properties | 3 +- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/ModCommand.java b/src/de/steamwar/bungeecore/commands/ModCommand.java index e9c7077..a60233e 100644 --- a/src/de/steamwar/bungeecore/commands/ModCommand.java +++ b/src/de/steamwar/bungeecore/commands/ModCommand.java @@ -1,40 +1,28 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Statement; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.UserGroup; import de.steamwar.command.SWCommand; +import jdk.internal.net.http.common.Pair; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLSyntaxErrorException; public class ModCommand extends SWCommand { - private static final Statement set = new Statement("UPDATE Mods Set ModType = ? WHERE ModName = ?"); + private static final Statement set = new Statement("UPDATE Mods Set ModType = ? WHERE ModName = ? AND ModType = ?"); private static final Statement findFirst = new Statement("SELECT * FROM Mods WHERE ModType = 0 LIMIT 1"); private static final Statement get = new Statement("SELECT * FROM Mods WHERE ModName = ?"); public ModCommand() { - super("mod", "bungeecore.teamchat", "mods"); + super("mod", "bungeecore.softreload", "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; - } - - boolean modExists = get.select(ResultSet::next,modName); - - System.out.println(modExists); + public void set(ProxiedPlayer p,String modName,String platform,Integer newModType) { + boolean modExists = get.select(ResultSet::next,modName,Mod.Platform.valueOf(platform)); if(!modExists) { Message.send("MOD_COMMAND_NOT_FOUND_IN_DATABASE",p,modName); @@ -46,19 +34,13 @@ public class ModCommand extends SWCommand { Message.send("MOD_CHANGED_TYPE",p,modName,newModType); } - @Register(value = {"next"},description = "MOD_COMMAND_NEXT_USAGE") + @Register() 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 -> { + Pair foundMod = findFirst.select(rs -> { if(rs.next()) { - return rs.getString("ModName"); + String name = rs.getString("ModName"); + Integer platform = rs.getInt("Platform"); + return new Pair<>(name,platform); } return null; }); @@ -68,6 +50,6 @@ public class ModCommand extends SWCommand { return; } - Message.send("MOD_FOUND_NEXT_MOD",p,foundMod); + Message.send("MOD_FOUND_NEXT_MOD",p,foundMod.first, Mod.Platform.getByValue(foundMod.second)); } } diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index dcd69ae..81e9045 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -71,6 +71,17 @@ public class Mod { public int get() { return value; } + + public static String getByValue(int val) { + String platform; + switch (val) { + case 0 : platform = "Forge"; + case 1: platform = "Labymod"; + case 2: platform = "Fabric"; + default: platform = ""; + } + return platform; + } } public enum ModType { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 3636dac..177b360 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -659,8 +659,7 @@ 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 +MOD_COMMAND_NOT_FOUND_IN_DATABASE=§7The Mod {0} on platform {1} was§c not §7found in the database! \ No newline at end of file