Solved Essentials Command /pay

Discussion in 'Bukkit Help' started by tg95, Jul 27, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    tg95

    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
     
  2. Offline

    Ruptur

    You would use a PlayerCommandPreprocessEvent to check for the command.
    Code:java
    1.  
    2. @EventHandler
    3. public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
    4. String command = event.getMessage();
    5.  
    6. if (command.startsWith("/pay ")) {
    7. String[] args = command.substring(4, command.length()).split(" ");
    8.  
    9. if (args.length >= 1) {
    10. String playerName = args[0];
    11.  
    12. if (playerName is something) {
    13. do something
    14. }
    15. }
    16. }
    17. }
    18.  


    Leave a like if you feel i helped :)
     
  3. Offline

    tg95

    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.
     
    Last edited by a moderator: Jun 11, 2016
  4. Offline

    Ruptur

    @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 :) )
     
  5. Offline

    tg95

    Man very thanks now is working :b

    Thanks ;b
     
  6. Offline

    Ruptur

    @tg95
    Glad to help :D
    Set the thread prefix to [Solved] if thats all

    Leave a like if you feel i helped :)
     
  7. Offline

    tg95

    done :b
     
Thread Status:
Not open for further replies.

Share This Page