From 58fb831950f3347d98cecd5e6bdb8c14185a6894 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 16 Jan 2023 20:11:58 +0100 Subject: [PATCH] Push fixes --- .../bungeecore/commands/ModCommand.java | 9 ++++----- src/de/steamwar/bungeecore/sql/Mod.java | 18 +++--------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/ModCommand.java b/src/de/steamwar/bungeecore/commands/ModCommand.java index 9825bec4..0c35fe40 100644 --- a/src/de/steamwar/bungeecore/commands/ModCommand.java +++ b/src/de/steamwar/bungeecore/commands/ModCommand.java @@ -64,7 +64,7 @@ public class ModCommand extends SWCommand { } public void updateAndCloseGui(Mod.ModType modType,String modName,Mod.Platform modPlatform,SWInventory toClose,ProxiedPlayer p) { - Mod.setMod(modType, modName, modPlatform); + Mod.get(modName,modPlatform).setModType(modType,modName,modPlatform); toClose.close(); openGui(p); } @@ -123,7 +123,7 @@ public class ModCommand extends SWCommand { return; } - Mod.setMod(newModType,modName,platform); + Mod.get(modName,platform).setModType(newModType,modName,platform); Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name()); } @@ -135,10 +135,9 @@ public class ModCommand extends SWCommand { @Register(value = {"next"}) public void next(ProxiedPlayer p) { - Pair foundMod = Mod.findFirstMod(); - Mod mod = Mod.get(foundMod.getKey(),foundMod.getValue()); + Mod mod = Mod.findFirstMod(); - if(foundMod == null) { + if(mod == null) { Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p); return; } diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index 7f9a1d4b..dc46205a 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -70,25 +70,13 @@ public class Mod { return get(modName,platform).modType; } - public static void setMod(Mod.ModType newModType,String modName,Mod.Platform platform) { + public void setModType(Mod.ModType newModType,String modName,Mod.Platform platform) { set.update(newModType.value ,modName,platform.value); } public static boolean doesModExist(String modName,Mod.Platform modPlatform) { return get.select(ResultSet::next,modName,modPlatform.value); } - - public static List getAll(int page, int elementsPerPage) { - return Mod.getAll.select(rs -> { - List f = new ArrayList<>(); - while(rs.next()){ - Mod entry = new Mod(rs.getString("ModName"), Mod.Platform.valueOf(rs.getInt("Platform")),Mod.ModType.valueOf(rs.getInt("ModType"))); - f.add(entry); - } - return f; - },page * elementsPerPage, elementsPerPage); - } - public static List getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) { return Mod.getAllFiltered.select(rs -> { List f = new ArrayList<>(); @@ -100,11 +88,11 @@ public class Mod { },filter.value, page * elementsPerPage, elementsPerPage); } - public static Pair findFirstMod() { + public static Mod findFirstMod() { findFirst.select(rs -> { String name = rs.getString("ModName"); int platform = rs.getInt("Platform"); - return new ImmutablePair<>(name,platform); + return get(name,Platform.valueOf(platform)); }); return null; }