Guest User

Op Help v. 1.2

a guest
Jul 11th, 2013
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.00 KB | None | 0 0
  1. package me.asura.opHelp;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. public class opHelp extends JavaPlugin {
  11.    
  12.     public void onEnalbe() {
  13.         Bukkit.getServer().getLogger().info("Op Help is now enabled!");
  14.     }
  15.    
  16.     public void onDisable() {
  17.         Bukkit.getServer().getLogger().info("Op Help is now disabled!");
  18.     }
  19.    
  20.     public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
  21.         //Command to send messages to op's
  22.         if(cmd.getName().equalsIgnoreCase("ophelp")) {
  23.            
  24.             if (!(sender instanceof Player)) {
  25.                 sender.sendMessage(ChatColor.RED + "Only players can use this command!");
  26.                 return true;
  27.             }
  28.            
  29.             //if no args were entered
  30.             if (args.length == 0) {
  31.                 sender.sendMessage(ChatColor.RED + "Please specify a player then write a message!");
  32.                 return true;
  33.             }
  34.            
  35.            
  36.             //Stating target as player specified
  37.             Player target = Bukkit.getServer().getPlayer(args[0]);
  38.            
  39.             //stating player as the sender
  40.             Player player = (Player) sender;
  41.            
  42.             //if the player could not be found
  43.             if (target == null) {
  44.                 sender.sendMessage(ChatColor.RED + "Could not find player " + args[0] + ".");
  45.                 return true;
  46.             }
  47.            
  48.             //if the sender only wrote who they would like to send it too
  49.             if (args.length == 1) {
  50.                 sender.sendMessage(ChatColor.RED + "Please write a message!");
  51.                 return true;
  52.             }
  53.            
  54.             if (target.isOp()) {
  55.            
  56.                 //Sends the message to specified player
  57.                 if (args.length == 2) {
  58.                
  59.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1]);
  60.                 }
  61.            
  62.                 if (args.length == 3) {
  63.                
  64.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2]);
  65.                 }
  66.            
  67.                 if (args.length == 4) {
  68.                
  69.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3]);
  70.                 }
  71.            
  72.                 if (args.length == 5) {
  73.                
  74.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4]);
  75.                 }
  76.            
  77.                 if (args.length == 6) {
  78.                
  79.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5]);
  80.                 }
  81.            
  82.                 if (args.length == 7) {
  83.                
  84.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6]);
  85.                 }
  86.            
  87.                 if (args.length == 8) {
  88.                
  89.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7]);
  90.                 }
  91.            
  92.                 if (args.length == 9) {
  93.                
  94.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8]);
  95.                 }
  96.            
  97.                 if (args.length == 10) {
  98.                
  99.                 target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9]);
  100.                 }
  101.            
  102.                 if (args.length == 11) {
  103.                
  104.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10]);
  105.                 }
  106.            
  107.                 if (args.length == 12) {
  108.            
  109.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11]);
  110.                 }
  111.            
  112.                 if (args.length == 13) {
  113.                
  114.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12]);
  115.                 }
  116.            
  117.                 if (args.length == 14) {
  118.                
  119.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[13]);
  120.                 }
  121.            
  122.                 if (args.length == 15) {
  123.                
  124.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14]);
  125.                 }
  126.            
  127.  
  128.                 if (args.length == 16) {
  129.                
  130.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15]);
  131.                 }
  132.            
  133.                 if (args.length == 17) {
  134.                
  135.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15] + " " + args[16]);
  136.                 }
  137.            
  138.                 if (args.length == 18) {
  139.                
  140.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15] + " " + args[16] + " " + args[17]);
  141.                 }
  142.            
  143.                 if (args.length == 19) {
  144.                
  145.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15] + " " + args[16] + " " + args[17] + " " + args[18]);
  146.                 }
  147.            
  148.                 if (args.length == 20) {
  149.                
  150.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15] + " " + args[16] + " " + args[17] + " " + args[18] + " " + args[19]);
  151.                 }
  152.            
  153.                 if (args.length == 21) {
  154.                    
  155.                     target.sendMessage(ChatColor.GREEN + "<" + ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN + " to " + ChatColor.DARK_AQUA + args[0] + ChatColor.GREEN + "> " + ChatColor.WHITE + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + " " + args[6] + " " + args[7] + " " + args[8] + " " + args[9] + " " + args[10] + " " + args[11] + " " + args[12] + " " + args[12] + " " + args[14] + " " + args[15] + " " + args[16] + " " + args[17] + " " + args[18] + " " + args[19] + " " + args[20]);
  156.                 }
  157.            
  158.                 if (args.length > 21) {
  159.                     sender.sendMessage(ChatColor.RED + "To many words! a maximum of 20!");
  160.                 }
  161.             }
  162.            
  163.             else {
  164.                 sender.sendMessage(ChatColor.RED + "This player is not op!");
  165.                 return true;
  166.             }
  167.         }
  168.        
  169.         //check if a specified player is opped
  170.         if (cmd.getName().equalsIgnoreCase("opcheck")) {
  171.            
  172.             //if sender does not specify a player
  173.             if (args.length == 0) {
  174.                 sender.sendMessage(ChatColor.RED + "Please specify a player");
  175.                 return true;
  176.             }
  177.            
  178.             if (args.length == 2) {
  179.                 sender.sendMessage(ChatColor.RED + "Use of this command is; /opcheck [player]");
  180.                 return true;
  181.             }
  182.            
  183.             //Stating target as player specified
  184.             Player target = Bukkit.getServer().getPlayer(args[0]);
  185.            
  186.             //when the player specify a player
  187.             if (args.length == 1) {
  188.                
  189.                 //if the player could not be found
  190.                 if (target == null) {
  191.                     sender.sendMessage(ChatColor.RED + "Could not find player " + args[0] + ".");
  192.                     return true;
  193.                 }
  194.            
  195.                 if (target.isOp()) {
  196.                     sender.sendMessage(ChatColor.GREEN + "Player " + args[0] + " is op!");
  197.                     return true;
  198.                 }
  199.            
  200.                 if (!(target.isOp())) {
  201.                     sender.sendMessage(ChatColor.RED + "Player " + args[0] + " is not op!");
  202.                     return true;
  203.                 }
  204.             }
  205.         }
  206.         return true;
  207.     }
  208.  
  209. }
Advertisement
Add Comment
Please, Sign In to add comment