Add KitId
Dieser Commit ist enthalten in:
Ursprung
f760ce58d9
Commit
63d59121b3
@ -31,6 +31,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
public class PersonalKit {
|
public class PersonalKit {
|
||||||
|
|
||||||
|
private final int kitID;
|
||||||
private final int userID;
|
private final int userID;
|
||||||
private String name;
|
private String name;
|
||||||
private final String gamemode;
|
private final String gamemode;
|
||||||
@ -38,6 +39,7 @@ public class PersonalKit {
|
|||||||
private String armor;
|
private String armor;
|
||||||
|
|
||||||
private PersonalKit(ResultSet rs) throws SQLException {
|
private PersonalKit(ResultSet rs) throws SQLException {
|
||||||
|
kitID = rs.getInt("KitID");
|
||||||
userID = rs.getInt("UserID");
|
userID = rs.getInt("UserID");
|
||||||
gamemode = rs.getString("GameMode");
|
gamemode = rs.getString("GameMode");
|
||||||
inventory = rs.getString("Inventory");
|
inventory = rs.getString("Inventory");
|
||||||
@ -68,7 +70,7 @@ public class PersonalKit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PersonalKit create(int userID, String gamemode, String name, ItemStack[] inventory, ItemStack[] armor){
|
public static void create(int userID, String gamemode, String name, ItemStack[] inventory, ItemStack[] armor){
|
||||||
YamlConfiguration inventoryConfig = new YamlConfiguration();
|
YamlConfiguration inventoryConfig = new YamlConfiguration();
|
||||||
inventoryConfig.set("Inventory", inventory);
|
inventoryConfig.set("Inventory", inventory);
|
||||||
|
|
||||||
@ -76,8 +78,7 @@ public class PersonalKit {
|
|||||||
armorConfig.set("Armor", armor);
|
armorConfig.set("Armor", armor);
|
||||||
|
|
||||||
SQL.update("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor)",
|
SQL.update("INSERT INTO PersonalKit (UserID, GameMode, Name, Inventory, Armor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Inventory = VALUES(Inventory), Armor = VALUES(Armor)",
|
||||||
userID, gamemode, inventoryConfig.saveToString(), armorConfig.saveToString());
|
userID, gamemode, name, inventoryConfig.saveToString(), armorConfig.saveToString());
|
||||||
return get(userID, gamemode, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getInventory(){
|
public ItemStack[] getInventory(){
|
||||||
@ -104,7 +105,7 @@ public class PersonalKit {
|
|||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
SQL.update("UPDATE PersonalKit SET Name = ?", this.name);
|
SQL.update("UPDATE PersonalKit SET Name = ? WHERE KitID = ?", this.name, kitID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInventory(ItemStack[] inventory) {
|
public void setInventory(ItemStack[] inventory) {
|
||||||
@ -112,7 +113,7 @@ public class PersonalKit {
|
|||||||
inventoryConfig.set("Inventory", inventory);
|
inventoryConfig.set("Inventory", inventory);
|
||||||
|
|
||||||
this.inventory = inventoryConfig.saveToString();
|
this.inventory = inventoryConfig.saveToString();
|
||||||
SQL.update("UPDATE PersonalKit SET Inventory = ?", this.inventory);
|
SQL.update("UPDATE PersonalKit SET Inventory = ? WHERE KitID = ?", this.inventory, kitID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArmor(ItemStack[] armor) {
|
public void setArmor(ItemStack[] armor) {
|
||||||
@ -120,6 +121,10 @@ public class PersonalKit {
|
|||||||
armorConfig.set("Armor", armor);
|
armorConfig.set("Armor", armor);
|
||||||
|
|
||||||
this.armor = armorConfig.saveToString();
|
this.armor = armorConfig.saveToString();
|
||||||
SQL.update("UPDATE PersonalKit SET Armor = ?", this.armor);
|
SQL.update("UPDATE PersonalKit SET Armor = ? WHERE KitID = ?", this.armor, kitID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
SQL.update("DELETE FROM `PersonalKit` WHERE KitID = ?", kitID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren