2013-09-25 16:49:24 +02:00
|
|
|
package me.libraryaddict.disguise.commands;
|
2013-07-16 07:01:12 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import me.libraryaddict.disguise.DisguiseListener;
|
2013-09-25 16:49:24 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
2013-11-22 20:52:15 +01:00
|
|
|
import me.libraryaddict.disguise.utils.BaseDisguiseCommand;
|
|
|
|
|
2013-07-16 07:01:12 +02:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
2013-11-05 16:06:15 +01:00
|
|
|
public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
2013-07-16 07:01:12 +02:00
|
|
|
|
|
|
|
private DisguiseListener listener;
|
|
|
|
|
|
|
|
public DisguiseEntityCommand(DisguiseListener listener) {
|
|
|
|
this.listener = listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
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;
|
|
|
|
}
|
2013-11-18 12:50:39 +01:00
|
|
|
Disguise disguise;
|
2013-11-05 16:06:15 +01:00
|
|
|
try {
|
2013-11-18 12:50:39 +01:00
|
|
|
disguise = parseDisguise(sender, args);
|
2013-11-05 16:06:15 +01:00
|
|
|
} catch (Exception ex) {
|
2013-11-18 12:50:39 +01:00
|
|
|
if (ex.getMessage() != null && !ChatColor.getLastColors(ex.getMessage()).equals("")) {
|
2013-11-05 16:06:15 +01:00
|
|
|
sender.sendMessage(ex.getMessage());
|
2013-11-19 12:03:11 +01:00
|
|
|
} else if (ex.getCause() != null) {
|
2013-11-18 12:50:39 +01:00
|
|
|
ex.printStackTrace();
|
2013-07-16 07:01:12 +02:00
|
|
|
}
|
2013-11-18 12:50:39 +01:00
|
|
|
return true;
|
2013-11-05 16:06:15 +01:00
|
|
|
}
|
2013-11-18 12:50:39 +01:00
|
|
|
listener.setSlap(sender.getName(), disguise);
|
|
|
|
sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise it as a "
|
|
|
|
+ disguise.getType().toReadable() + "!");
|
2013-07-16 07:01:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the player the information
|
|
|
|
*/
|
2013-11-05 16:06:15 +01:00
|
|
|
protected void sendCommandUsage(CommandSender sender) {
|
2013-11-18 12:53:22 +01:00
|
|
|
ArrayList<String> allowedDisguises = getAllowedDisguises(sender);
|
2013-07-16 07:01:12 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then slap a entity to disguise it!");
|
|
|
|
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 + "/disguiseentity player <Name>");
|
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
|
|
|
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
|
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|