Package com.github.zathrus_writer.commandsex.commands

Source Code of com.github.zathrus_writer.commandsex.commands.Command_cex_cmdu

package com.github.zathrus_writer.commandsex.commands;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.github.zathrus_writer.commandsex.helpers.Commands;
import com.github.zathrus_writer.commandsex.helpers.LogHelper;
import com.github.zathrus_writer.commandsex.helpers.Utils;

/***
* CMDU - will run a command as another player
* @author Kezz101
* @param sender
* @param alias
* @param args
* @return
*/

public class Command_cex_cmdu {
 
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (args.length < 2){
      Commands.showCommandHelpAndUsage(sender, "cex_cmdu", alias);
      return true;
    }
   
    Player target = Bukkit.getServer().getPlayer(args[0]);
    // Collects the command and arguments into a string, ready for dispatching
    String cmd = Utils.collectArgs(args, 1);
   
    //Checks
    if(target == null) {
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    }
   
    if(Bukkit.getPluginCommand(args[1]) == null) {
      LogHelper.showWarning("invalidCommand", sender);
      return true;
    }
   
    //Execute!
    Bukkit.dispatchCommand(target, cmd);
   
    return true;
  }

}
TOP

Related Classes of com.github.zathrus_writer.commandsex.commands.Command_cex_cmdu

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.