SteamWar/BungeeCore
Archiviert
13
2

Push fixes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
zOnlyKroks 2023-01-04 20:31:31 +01:00
Ursprung e0a1542b03
Commit dc234b2b33
3 geänderte Dateien mit 24 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -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<String ,Integer> 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));
}
}

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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!
MOD_COMMAND_NOT_FOUND_IN_DATABASE=§7The Mod {0} on platform {1} was§c not §7found in the database!