Archiviert
1
0
Dieser Commit ist enthalten in:
zOnlyKroks 2023-01-16 20:11:58 +01:00
Ursprung fc5c4922db
Commit 58fb831950
2 geänderte Dateien mit 7 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -64,7 +64,7 @@ public class ModCommand extends SWCommand {
} }
public void updateAndCloseGui(Mod.ModType modType,String modName,Mod.Platform modPlatform,SWInventory toClose,ProxiedPlayer p) { 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(); toClose.close();
openGui(p); openGui(p);
} }
@ -123,7 +123,7 @@ public class ModCommand extends SWCommand {
return; 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()); Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name());
} }
@ -135,10 +135,9 @@ public class ModCommand extends SWCommand {
@Register(value = {"next"}) @Register(value = {"next"})
public void next(ProxiedPlayer p) { public void next(ProxiedPlayer p) {
Pair<String ,Integer> foundMod = Mod.findFirstMod(); Mod mod = Mod.findFirstMod();
Mod mod = Mod.get(foundMod.getKey(),foundMod.getValue());
if(foundMod == null) { if(mod == null) {
Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p); Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p);
return; return;
} }

Datei anzeigen

@ -70,25 +70,13 @@ public class Mod {
return get(modName,platform).modType; 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); set.update(newModType.value ,modName,platform.value);
} }
public static boolean doesModExist(String modName,Mod.Platform modPlatform) { public static boolean doesModExist(String modName,Mod.Platform modPlatform) {
return get.select(ResultSet::next,modName,modPlatform.value); return get.select(ResultSet::next,modName,modPlatform.value);
} }
public static List<Mod> getAll(int page, int elementsPerPage) {
return Mod.getAll.select(rs -> {
List<Mod> 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<Mod> getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) { public static List<Mod> getAllModsFiltered(int page,int elementsPerPage, Mod.ModType filter) {
return Mod.getAllFiltered.select(rs -> { return Mod.getAllFiltered.select(rs -> {
List<Mod> f = new ArrayList<>(); List<Mod> f = new ArrayList<>();
@ -100,11 +88,11 @@ public class Mod {
},filter.value, page * elementsPerPage, elementsPerPage); },filter.value, page * elementsPerPage, elementsPerPage);
} }
public static Pair<String,Integer> findFirstMod() { public static Mod findFirstMod() {
findFirst.select(rs -> { findFirst.select(rs -> {
String name = rs.getString("ModName"); String name = rs.getString("ModName");
int platform = rs.getInt("Platform"); int platform = rs.getInt("Platform");
return new ImmutablePair<>(name,platform); return get(name,Platform.valueOf(platform));
}); });
return null; return null;
} }