diff --git a/src/main/java/org/bitbiome/commands/CollectCommand.java b/src/main/java/org/bitbiome/commands/CollectCommand.java index ab29c5a..e235110 100644 --- a/src/main/java/org/bitbiome/commands/CollectCommand.java +++ b/src/main/java/org/bitbiome/commands/CollectCommand.java @@ -42,18 +42,21 @@ public class CollectCommand implements CommandAPI { } } } - 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); - getInventory.add(location.get(i)); - location.remove(i); + writeNewItem(location, getInventory, o1, inventory, i, jp, o); } } System.out.println("Es gibt kein Item, dass du einsammeln kannst."); } + public void writeNewItem(ArrayList location, ArrayList getInventory, JSONObject o1, JSONArray inventory, int i, JsonParser jp, JSONObject o){ + 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); + getInventory.add(location.get(i)); + location.remove(i); + } public void increaseAmountInPlayerConfig(JSONArray inventory, int k, JsonParser jp, JSONObject o){ JSONObject o2 = new JSONObject(); int amountItemsInPlayerconfig = 0;