Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.militiaspack.Murderfun;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public final class Main extends JavaPlugin {
- public void onEnable(){
- getLogger().info("Hide has been enabled!");
- getCommand("hide").setExecutor(this);
- }
- public void onDisable(){
- getLogger().info("Hide has been disabled!");
- }
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- Player player = (Player) sender; // You did this I just put it in a different place and stuff for my formatting OCD
- if(commandLabel.equalsIgnoreCase("Hide") && args.length == 1) { // If the command is hide and the arguement lengrh is = to 1 then...
- if (!(sender instanceof Player)) { // Check to make sure it is a player rather than a console
- sender.sendMessage(ChatColor.DARK_RED + "Only players can use this command!"); // send the message to the console
- }else{
- Player target = Bukkit.getServer().getPlayer(args[0]); // Get the target player
- if (target == null) { // If the player isn't online then...
- player.sendMessage(ChatColor.DARK_RED + "Player " + args[0] + " is not online."); // Added color and sent the message!
- }else{
- target.hidePlayer(player); // Hide the player
- String targetName = target.getName(); // Just making a string for the name of the player
- player.sendMessage(ChatColor.DARK_AQUA + "You have been hidden from " + targetName);
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement