public class ListLocations implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public ListLocations(Main plugin) {
this.plugin = plugin;
plugin.getCommand("listlocations").setExecutor(this);
System.out.println(1);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
System.out.println(2);
if(!(sender instanceof Player)) {
sender.sendMessage("Only players can use commands for this plugin");
return false;
}
System.out.println(3);
Gson gson = new Gson();
Reader reader = null;
try {
reader = Files.newBufferedReader(Paths.get("C:\\Users\\gaela\\OneDrive\\Documents\\advanedChorusFruitPlugin\\src\\me\\JiovannyAlejos\\advancedChorusFruit\\tpData.json"));
} catch (IOException e) {e.printStackTrace();}
CoordinateData data = gson.fromJson(reader, CoordinateData.class);
String coordList = "List of warp locations\n";
if(data.coordinates.size() == 0) {
coordList = "No warp locations set";
} else {
ArrayList<String> names = data.locNames;
for(int i = 0; i < data.coordinates.size(); i++) {
String[] coordinates = data.coordinates.get(i).split(Pattern.quote("|"));
coordList += "\n" + names.get(i) + ", " + coordinates[0] + ", " + coordinates[1] + ", " + coordinates[2];
}
}
Player p = (Player) sender;
p.sendMessage(coordList);
return true;
}
}
why is it that this only ever outputs 1 but never 2 or 3, and it doesn't send the player the message either