2013-09-25 16:49:24 +02:00
|
|
|
package me.libraryaddict.disguise.commands;
|
2013-07-16 07:01:12 +02:00
|
|
|
|
2014-06-01 18:14:35 +02:00
|
|
|
import me.libraryaddict.disguise.DisguiseConfig;
|
2015-03-30 04:47:29 +02:00
|
|
|
import me.libraryaddict.disguise.LibsDisguises;
|
2013-09-25 16:49:24 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
2014-06-14 10:16:48 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
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;
|
|
|
|
|
2016-02-19 20:23:46 +01:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2013-11-05 16:06:15 +01:00
|
|
|
public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
2013-07-16 07:01:12 +02:00
|
|
|
|
|
|
|
@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 {
|
2014-06-14 10:16:48 +02:00
|
|
|
disguise = parseDisguise(sender, args, getPermissions(sender));
|
2014-09-16 17:41:04 +02:00
|
|
|
} catch (DisguiseParseException ex) {
|
|
|
|
if (ex.getMessage() != null) {
|
2013-11-05 16:06:15 +01:00
|
|
|
sender.sendMessage(ex.getMessage());
|
2013-07-16 07:01:12 +02:00
|
|
|
}
|
2013-11-18 12:50:39 +01:00
|
|
|
return true;
|
2015-07-07 17:30:12 +02:00
|
|
|
} catch (IllegalAccessException | InvocationTargetException ex) {
|
2015-03-30 04:47:29 +02:00
|
|
|
ex.printStackTrace(System.out);
|
2014-09-16 17:41:04 +02:00
|
|
|
return true;
|
2013-11-05 16:06:15 +01:00
|
|
|
}
|
2016-02-19 20:23:46 +01:00
|
|
|
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
2014-06-01 18:14:35 +02:00
|
|
|
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
|
|
|
|
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
2013-07-16 07:01:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the player the information
|
2015-08-03 00:39:44 +02:00
|
|
|
*
|
2015-03-31 05:07:47 +02:00
|
|
|
* @param sender
|
|
|
|
* @param map
|
2013-07-16 07:01:12 +02:00
|
|
|
*/
|
2015-03-31 05:07:47 +02:00
|
|
|
@Override
|
2014-06-14 10:16:48 +02:00
|
|
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
|
|
|
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
2014-05-05 11:34:19 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");
|
2013-07-16 07:01:12 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
|
|
|
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
2015-08-03 00:39:44 +02:00
|
|
|
if (allowedDisguises.contains("player")) {
|
2013-07-16 07:01:12 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>");
|
2015-08-03 00:39:44 +02:00
|
|
|
}
|
2014-04-04 07:30:20 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
|
2015-08-03 00:39:44 +02:00
|
|
|
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
2013-07-16 07:01:12 +02:00
|
|
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
|
2015-08-03 00:39:44 +02:00
|
|
|
}
|
2013-07-16 07:01:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|