From e68f5314e15b7bbba755011782727d746497a330 Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Tue, 24 Jan 2023 12:50:41 +0100 Subject: [PATCH] Adapted to f8926e04962cffd427a2ea5754b0d9f909c83596 --- .../org/bitbiome/commands/UseCommand.java | 75 +++++++------------ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/bitbiome/commands/UseCommand.java b/src/main/java/org/bitbiome/commands/UseCommand.java index 61eb376..4302f7d 100644 --- a/src/main/java/org/bitbiome/commands/UseCommand.java +++ b/src/main/java/org/bitbiome/commands/UseCommand.java @@ -1,67 +1,48 @@ package org.bitbiome.commands; +import java.util.ArrayList; import java.util.Scanner; -import org.bitbiome.classes.JsonParser; -import org.bitbiome.classes.TravelEngine; -import org.json.*; +import org.bitbiome.classes.*; +import org.bitbiome.entities.*; public class UseCommand implements CommandAPI { @Override public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine engine) { - System.out.println(getUseMessage(message.split(" ", 2)[1])); + System.out.println(getUseMessage(message.split(" ", 2)[1], engine)); } - private String getUseMessage(String msg) { + private String getUseMessage(String msg, TravelEngine engine) { + Player player = engine.getPlayer(); String message[] = msg.split(" on "); String itemName = message[0]; - JSONObject item = getItem(itemName), target; - JsonParser p = new JsonParser(); + ArrayList inv = player.getInventory(); - if(item == null) - return "You don't have that item."; - if(item.getBoolean("attack")) - return "You can't attack with this."; - if(message.length == 1) - target = p.getJSONObject("playerconfig.json"); - else - target = getTarget(message[1]); - if(target == null) - return "That target is not available."; - return useItem(item, target); + for(int i = 0; i mobs = player.getLocation().getMobList(); + for(int j = 0; j