i want to type /sp to save my position in the config, then /sp again to save the next position, and so on but my code doesnt quite work. the first time i use the command it saves my posistion in the config but still returns false, and the second time i use it, it saves my position again but overwrites first position and still returns false. any ideas? Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args ){ int point = 1; if(cmd.getName().equalsIgnoreCase("sp")){ Player p = (Player)sender; double x = p.getLocation().getX(); double y = p.getLocation().getY(); double z = p.getLocation().getZ(); getConfig().set(point + " x", x); getConfig().set(point + " y", y); getConfig().set(point + " z", z); saveConfig(); p.sendMessage(ChatColor.BLUE + "You have set the spawn point for player " + point); point ++; } return false; }
Make point static. The value of a local variable is not persistent across invocations of the block they are defined in. You'll likely have to save it in the config as well and load it when your plugin is enabled.