Browse Source

refactoring: created method increaseAmountInPlayerConfig() in CollectCommand.java

remotes/origin/Julia
Juliakn66 2 years ago
parent
commit
8fe445b5f8
  1. 15
      src/main/java/org/bitbiome/commands/CollectCommand.java

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

@ -36,12 +36,7 @@ public class CollectCommand implements CommandAPI {
getInventory.get(j).setAmount(getInventory.get(j).getAmount() + 1); getInventory.get(j).setAmount(getInventory.get(j).getAmount() + 1);
for (int k = 0; k < inventory.length(); k++) { for (int k = 0; k < inventory.length(); k++) {
if (inventory.getJSONObject(k).getString("name").equals(item)) { 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 eingesammelt.");
increaseAmountInPlayerConfig(inventory,k,jp,o);
return; return;
} }
} }
@ -59,5 +54,13 @@ public class CollectCommand implements CommandAPI {
} }
} System.out.println("Es gibt kein Item, dass du einsammeln kannst."); } System.out.println("Es gibt kein Item, dass du einsammeln kannst.");
} }
public void increaseAmountInPlayerConfig(JSONArray inventory, int k, JsonParser jp, JSONObject o){
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 eingesammelt.");
}
} }
Loading…
Cancel
Save