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