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){ 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)", 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); return get(userID, gamemode, name);
} }
@ -128,11 +128,11 @@ public class PersonalKit {
return inUse; return inUse;
} }
public void setInUse(boolean inUse) { public void setInUse() {
PersonalKit kit = getKitInUse(userID, gamemode); PersonalKit kit = getKitInUse(userID, gamemode);
if(kit != null) if(kit != null)
kit.setUse(inUse); kit.setUse(false);
setUse(inUse); setUse(true);
} }
private void setUse(boolean inUse) { private void setUse(boolean inUse) {
@ -146,18 +146,18 @@ public class PersonalKit {
} }
public void setInventory(ItemStack[] inventory) { public void setInventory(ItemStack[] inventory) {
this.inventory = getInventoryConfig(inventory); this.inventory = saveInvConfig("Inventory", inventory);
updateDB(); updateDB();
} }
public void setArmor(ItemStack[] armor) { public void setArmor(ItemStack[] armor) {
this.armor = getArmorConfig(armor); this.armor = saveInvConfig("Armor", armor);
updateDB(); updateDB();
} }
public void setContainer(ItemStack[] inventory, ItemStack[] armor) { public void setContainer(ItemStack[] inventory, ItemStack[] armor) {
this.armor = getArmorConfig(armor); this.armor = saveInvConfig("Armor", armor);
this.inventory = getInventoryConfig(inventory); this.inventory = saveInvConfig("Inventory", inventory);
updateDB(); updateDB();
} }
@ -165,16 +165,9 @@ public class PersonalKit {
SQL.update("DELETE FROM `PersonalKit` WHERE KitID = ?"); SQL.update("DELETE FROM `PersonalKit` WHERE KitID = ?");
} }
private static String getInventoryConfig(ItemStack[] inventory) { private static String saveInvConfig(String name, ItemStack[] inv) {
YamlConfiguration inventoryConfig = new YamlConfiguration();
inventoryConfig.set("Inventory", inventory);
return inventoryConfig.saveToString();
}
private static String getArmorConfig(ItemStack[] armor) {
YamlConfiguration armorConfig = new YamlConfiguration(); YamlConfiguration armorConfig = new YamlConfiguration();
armorConfig.set("Armor", armor); armorConfig.set(name, inv);
return armorConfig.saveToString(); return armorConfig.saveToString();
} }