Browse Source

edited method collectItem() of CollectCommand

remotes/origin/Julia
Juliakn66 2 years ago
parent
commit
ec1ee44981
  1. 32
      src/main/java/org/bitbiome/commands/CollectCommand.java

32
src/main/java/org/bitbiome/commands/CollectCommand.java

@ -16,7 +16,37 @@ public class CollectCommand implements CommandAPI {
} }
public void collectItem(ArrayList<Item> location, String item, JsonParser jp, JSONObject o, JSONArray inventory, TravelEngine travelEngine) { public void collectItem(ArrayList<Item> location, String item, JsonParser jp, JSONObject o, JSONArray inventory, TravelEngine travelEngine) {
for (int i = 0; i < location.size(); i++) {
if (item.equals(location.get(i).getName())) {
JSONObject o1 = new JSONObject();
for (int j = 0; j < travelEngine.getPlayer().getInventory().size(); j++) {
if (travelEngine.getPlayer().getInventory().get(j).getName().equals(item)) {
travelEngine.getPlayer().getInventory().get(j).setAmount(travelEngine.getPlayer().getInventory().get(j).getAmount() + 1);
for (int k = 0; k < inventory.length(); k++) {
if (inventory.getJSONObject(k).getString("name").equals(item)) {
JSONObject o2 = new JSONObject();
int amountItemsInPlayerconfig = 0;
amountItemsInPlayerconfig = inventory.getJSONObject(k).getInt("amount");
inventory.getJSONObject(k).put("amount", amountItemsInPlayerconfig + 1);
jp.writeObject("playerconfig.json", o);
System.out.println("Du hast das Item eingsammelt.");
return;
}
}
}
}
o1.put("name", location.get(i).getName());
o1.put("doesDamage", location.get(i).doesDamage());
o1.put("damage", location.get(i).getDamage());
o1.put("amount", 1);
o1.put("durability", 1000);
o.getJSONArray("inventory").put(o1);
jp.writeObject("playerconfig.json", o);
travelEngine.getPlayer().getInventory().add(location.get(i));
location.remove(i);
return;
}
} System.out.println("Es gibt kein Item, dass du einsammeln kannst.");
} }
} }
Loading…
Cancel
Save