From c8c99c21fe2892ec0f4308da9c68b9fd582293db Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 27 Jan 2021 12:23:23 +0100 Subject: [PATCH] Fixing... --- .../src/de/steamwar/sql/PersonalKit.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/PersonalKit.java b/SpigotCore_Main/src/de/steamwar/sql/PersonalKit.java index a0afac1..9db33f0 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/PersonalKit.java +++ b/SpigotCore_Main/src/de/steamwar/sql/PersonalKit.java @@ -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(); }