How to I make a Targetable Command?

Discussion in 'Plugin Development' started by Blackwolf700, Aug 30, 2015.

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

    Blackwolf700

    I want to make a fake OP plugin but I cannot figure out how to make a command in this form "/fakeop {name}" So far, I got it up to here.

    All I want this to do is be target able.
    Code:
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    
            if (!(sender instanceof Player)) {
                sender.sendMessage("You must be a player to use this command!");
                return false;
      
    
            }
          
                    Player player = (Player) sender;
                    player.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "[Server: Opped " + player.getName() + "]");
                    player.sendMessage(ChatColor.YELLOW + "You have been oped!");
                    player.playSound(player.getLocation(), Sound.WITHER_DEATH, 2F, 1F);
                    return true;
              
        }
    
          
          
                   }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Blackwolf700 Check if args > 0
    If so: get the player with the name said in args[0]
     
    Nebuler likes this.
  3. Offline

    Blackwolf700

    I'm sorry. I am still pretty new to this. Can you explain what you mean by "Check if args > 0"?
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    Blackwolf700

    I'm very sorry, I cannot find anywhere in my code where i put a args > 0. :(

    Nvm! I figured out my issue. I never even thought of adding a target. :p Thanks for helping me!

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Aug 31, 2015
  6. Offline

    mythbusterma

Thread Status:
Not open for further replies.

Share This Page