Hi all, i have one quest. My quest is: dont have any code or any, for if player use command /pay target check target can recive money? Sorry for my bad english and thanks for help
You would use a PlayerCommandPreprocessEvent to check for the command. Code:java @EventHandlerpublic void onCommandPreProcess(PlayerCommandPreprocessEvent event) { String command = event.getMessage(); if (command.startsWith("/pay ")) { String[] args = command.substring(4, command.length()).split(" "); if (args.length >= 1) { String playerName = args[0]; if (playerName is something) { do something } } }} Leave a like if you feel i helped
Thanks for help, but have another quest, can example use: if (! playername.haspermission("can.recive.money") { i go try this: Code: @EventHandler public void onCommandPreProcess(PlayerCommandPreprocessEvent event) { String command = event.getMessage(); if (command.startsWith("/pay ")) { String[] args = command.substring(4, command.length()).split(" "); if (args.length >= 1) { Player target = Bukkit.getPlayer(args[0]); if (target.hasPermission("")) { } } } } EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@tg95 You should probably add a null check to check if the target player is online and not null before doing things with it (Remeber to tahg people so they recieve an alert )