Im making a plugin that subtracts money of the executor of the command (using essentials API), but i have a problem. I don t know to put the player to substract the money! I tried but i can t use in the method subtract , (Player, double)in essentials API! Here its the code: Code: public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { if (command.getName().equalsIgnoreCase("test")) return test(sender, args); return true; } private boolean test(CommandSender sender, String[] args) { // comandos Player p = sender.getPlayer(); subtract(p,1000000); return true; }
Why dont you just pit it all into the same method? Code: public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if(label.equalsIgnoreCase("test")) { if((cs instanceof Player)) { Player p = (Player)cs; subtract(p, Integer.valueOf(args[0])); } } return false; } This will do the exact thing you want but more compact and able to accept the argument after /test EXAMPLE: /test 1000 will take $1,000 away from you.
@ElCreeperHD Did you static import the method subtract else then it wouldnt work because the method subtract doesnt exist