LibsDisguises/src/me/libraryaddict/disguise/commands/DisguiseCommand.java

48 lines
2.1 KiB
Java
Raw Normal View History

package me.libraryaddict.disguise.commands;
2013-05-17 23:05:19 +02:00
import java.util.ArrayList;
import me.libraryaddict.disguise.BaseDisguiseCommand;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
2013-05-17 23:05:19 +02:00
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class DisguiseCommand extends BaseDisguiseCommand {
2013-05-29 00:52:54 +02:00
@Override
2013-05-17 23:05:19 +02:00
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.getName().equals("CONSOLE")) {
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
return true;
}
try {
Disguise disguise = parseDisguise(sender, args);
DisguiseAPI.disguiseToAll((Player) sender, disguise);
2013-11-05 17:05:04 +01:00
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
} catch (Exception ex) {
if (ex.getMessage() != null) {
sender.sendMessage(ex.getMessage());
}
}
2013-05-17 23:05:19 +02:00
return true;
}
/**
* Send the player the information
*/
protected void sendCommandUsage(CommandSender sender) {
ArrayList<String> allowedDisguises = getAllowedDisguises(sender, "disguise");
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player"))
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>");
}
2013-05-17 23:05:19 +02:00
}