Advertisement
Guest User

Untitled

a guest
Dec 8th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. package io.github.militiaspack.Murderfun;
  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 final class Main extends JavaPlugin {
  11.  
  12.     public void onEnable(){
  13.         getLogger().info("Hide has been enabled!");
  14.         getCommand("hide").setExecutor(this);
  15.     }
  16.  
  17.     public void onDisable(){
  18.         getLogger().info("Hide has been disabled!");
  19.     }
  20.  
  21.     public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  22.         Player player = (Player) sender; // You did this I just put it in a different place and stuff for my formatting OCD
  23.        
  24.         if(commandLabel.equalsIgnoreCase("Hide") && args.length == 1) { // If the command is hide and the arguement lengrh is = to 1 then...
  25.             if (!(sender instanceof Player)) { // Check to make sure it is a player rather than a console
  26.                 sender.sendMessage(ChatColor.DARK_RED + "Only players can use this command!"); // send the message to the console
  27.             }else{
  28.                 Player target = Bukkit.getServer().getPlayer(args[0]); // Get the target player
  29.                 if (target == null) { // If the player isn't online then...
  30.                     player.sendMessage(ChatColor.DARK_RED + "Player " + args[0] + " is not online."); // Added color and sent the message!
  31.  
  32.                 }else{
  33.                     target.hidePlayer(player); // Hide the player
  34.                     String targetName = target.getName(); // Just making a string for the name of the player
  35.                    
  36.                     player.sendMessage(ChatColor.DARK_AQUA + "You have been hidden from " + targetName);
  37.                 }
  38.                
  39.             }
  40.         }
  41.         return true;
  42.  
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement