SteamWar/FightSystem
Archiviert
13
1
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-07-06 21:58:45 +02:00
Ursprung 6060de639e
Commit d8963cc189
2 geänderte Dateien mit 3 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -10,15 +10,13 @@ public class Kit {
private boolean leaderAllowed; private boolean leaderAllowed;
private boolean memberAllowed; private boolean memberAllowed;
private ItemStack[] inventory; private ItemStack[] inventory;
private ItemStack[] armor;
public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] armor, ItemStack[] inventory) { public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] inventory) {
this.name = name; this.name = name;
this.price = price; this.price = price;
this.leaderAllowed = leaderAllowed; this.leaderAllowed = leaderAllowed;
this.memberAllowed = memberAllowed; this.memberAllowed = memberAllowed;
this.inventory = inventory; this.inventory = inventory;
this.armor = armor;
} }
public String getName() { public String getName() {
@ -41,12 +39,7 @@ public class Kit {
return inventory; return inventory;
} }
public ItemStack[] getArmor() {
return armor;
}
public void loadToPlayer(Player player) { public void loadToPlayer(Player player) {
player.getInventory().setContents(inventory); player.getInventory().setContents(inventory);
player.getInventory().setArmorContents(armor);
} }
} }

Datei anzeigen

@ -20,7 +20,7 @@ public class KitManager {
private static final ArrayList<Kit> loadedKits = new ArrayList<>(); private static final ArrayList<Kit> loadedKits = new ArrayList<>();
public static void saveInventory(String kitName, Player player){ public static void saveInventory(String kitName, Player player){
loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getArmorContents(), player.getInventory().getContents())); loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getContents()));
saveAllKits(); saveAllKits();
} }
@ -43,14 +43,13 @@ public class KitManager {
FileConfiguration data = instance.getKitData(); FileConfiguration data = instance.getKitData();
String path = "Kits." + name; String path = "Kits." + name;
if(data.contains(path)) { if(data.contains(path)) {
List<ItemStack> armor = (List<ItemStack>) data.getList(path + ".Armor");
List<ItemStack> items = (List<ItemStack>) data.getList(path + ".Items"); List<ItemStack> items = (List<ItemStack>) data.getList(path + ".Items");
int price = data.getInt(path + ".Price"); int price = data.getInt(path + ".Price");
boolean leaderAllowed = data.getBoolean(path + ".LeaderAllowed"); boolean leaderAllowed = data.getBoolean(path + ".LeaderAllowed");
boolean memberAllowed = data.getBoolean(path + ".MemberAllowed"); boolean memberAllowed = data.getBoolean(path + ".MemberAllowed");
Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, armor.toArray(new ItemStack[1]), items.toArray(new ItemStack[1])); Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, items.toArray(new ItemStack[1]));
return kit; return kit;
} }
return null; return null;
@ -68,7 +67,6 @@ public class KitManager {
YamlConfiguration yamlConfiguration = new YamlConfiguration(); YamlConfiguration yamlConfiguration = new YamlConfiguration();
for(Kit k : loadedKits){ for(Kit k : loadedKits){
String path = "Kits." + k.getName(); String path = "Kits." + k.getName();
yamlConfiguration.set(path + ".Armor", k.getArmor());
yamlConfiguration.set(path + ".Items", k.getInventory()); yamlConfiguration.set(path + ".Items", k.getInventory());
yamlConfiguration.set(path + ".Price", k.getPrice()); yamlConfiguration.set(path + ".Price", k.getPrice());
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed()); yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());