SteamWar/SpigotCore
Archiviert
13
0
Dieser Commit ist enthalten in:
Chaoscaot 2021-01-27 12:23:23 +01:00
Ursprung fe050d76a4
Commit c8c99c21fe

Datei anzeigen

@ -72,7 +72,7 @@ public class PersonalKit {
public static PersonalKit create(int userID, String gamemode, String name, ItemStack[] inventory, ItemStack[] armor){
SQL.update("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor), Name = VALUES(name)",
userID, gamemode, name, getInventoryConfig(inventory), getArmorConfig(armor));
userID, gamemode, name, saveInvConfig("Inventory", inventory), saveInvConfig("Armor", armor));
return get(userID, gamemode, name);
}
@ -128,11 +128,11 @@ public class PersonalKit {
return inUse;
}
public void setInUse(boolean inUse) {
public void setInUse() {
PersonalKit kit = getKitInUse(userID, gamemode);
if(kit != null)
kit.setUse(inUse);
setUse(inUse);
kit.setUse(false);
setUse(true);
}
private void setUse(boolean inUse) {
@ -146,18 +146,18 @@ public class PersonalKit {
}
public void setInventory(ItemStack[] inventory) {
this.inventory = getInventoryConfig(inventory);
this.inventory = saveInvConfig("Inventory", inventory);
updateDB();
}
public void setArmor(ItemStack[] armor) {
this.armor = getArmorConfig(armor);
this.armor = saveInvConfig("Armor", armor);
updateDB();
}
public void setContainer(ItemStack[] inventory, ItemStack[] armor) {
this.armor = getArmorConfig(armor);
this.inventory = getInventoryConfig(inventory);
this.armor = saveInvConfig("Armor", armor);
this.inventory = saveInvConfig("Inventory", inventory);
updateDB();
}
@ -165,16 +165,9 @@ public class PersonalKit {
SQL.update("DELETE FROM `PersonalKit` WHERE KitID = ?");
}
private static String getInventoryConfig(ItemStack[] inventory) {
YamlConfiguration inventoryConfig = new YamlConfiguration();
inventoryConfig.set("Inventory", inventory);
return inventoryConfig.saveToString();
}
private static String getArmorConfig(ItemStack[] armor) {
private static String saveInvConfig(String name, ItemStack[] inv) {
YamlConfiguration armorConfig = new YamlConfiguration();
armorConfig.set("Armor", armor);
armorConfig.set(name, inv);
return armorConfig.saveToString();
}