Browse Source

Added getTarget() function

remotes/origin/fight-engine
fdai7430 2 years ago
parent
commit
b4bc493d05
  1. 18
      src/main/java/org/bitbiome/commands/UseCommand.java

18
src/main/java/org/bitbiome/commands/UseCommand.java

@ -30,4 +30,22 @@ public class UseCommand implements CommandAPI {
} }
return null; return null;
} }
private JSONObject getTarget(String target) {
String currentLocation = JsonParser.getJSONObject("playerconfig").getString("currentLocation");
JSONArray locations = JsonParser.getJSONObject("gameconfig").getJSONArray("locations");
for(int i = 0; i < locations.length(); i++) {
JSONObject location = locations.getJSONObject(i);
if(locations.getJSONObject(i).getString("name").equals(currentLocation)) {
JSONArray targets = location.getJSONArray("mobs");
for(int j = 0; j < targets.length(); j++) {
JSONObject mob = targets.getJSONObject(j);
if(mob.getString("name").equals(target))
return mob;
}
break;
}
}
return null;
}
} }
Loading…
Cancel
Save