Current progress
This commit is contained in:
@@ -36,7 +36,8 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
||||
return new ArrayList<String>(new HashSet<String>(list));
|
||||
}
|
||||
|
||||
protected ArrayList<String> getAllowedDisguises(HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||
protected ArrayList<String> getAllowedDisguises(
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||
|
||||
for (DisguisePerm type : hashMap.keySet()) {
|
||||
@@ -52,7 +53,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected String[] getArgs(String[] args) {
|
||||
ArrayList<String> newArgs = new ArrayList<String>();
|
||||
ArrayList<String> newArgs = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
@@ -69,29 +70,21 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
||||
public final String getPermNode() {
|
||||
if (this instanceof DisguiseCommand) {
|
||||
return "disguise";
|
||||
}
|
||||
else if (this instanceof DisguiseEntityCommand) {
|
||||
} else if (this instanceof DisguiseEntityCommand) {
|
||||
return "disguiseentity";
|
||||
}
|
||||
else if (this instanceof DisguisePlayerCommand) {
|
||||
} else if (this instanceof DisguisePlayerCommand) {
|
||||
return "disguiseplayer";
|
||||
}
|
||||
else if (this instanceof DisguiseRadiusCommand) {
|
||||
} else if (this instanceof DisguiseRadiusCommand) {
|
||||
return "disguiseradius";
|
||||
}
|
||||
else if (this instanceof DisguiseModifyCommand) {
|
||||
} else if (this instanceof DisguiseModifyCommand) {
|
||||
return "disguisemodify";
|
||||
}
|
||||
else if (this instanceof DisguiseModifyEntityCommand) {
|
||||
} else if (this instanceof DisguiseModifyEntityCommand) {
|
||||
return "disguisemodifyentity";
|
||||
}
|
||||
else if (this instanceof DisguiseModifyPlayerCommand) {
|
||||
} else if (this instanceof DisguiseModifyPlayerCommand) {
|
||||
return "disguisemodifyplayer";
|
||||
}
|
||||
else if (this instanceof DisguiseModifyRadiusCommand) {
|
||||
} else if (this instanceof DisguiseModifyRadiusCommand) {
|
||||
return "disguisemodifyradius";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unknown disguise command, perm node not found");
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -30,7 +31,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Entity)) {
|
||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,9 +71,11 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Now disguised as a %s"),
|
||||
disguise.getType().toReadable()));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to disguise as a " + disguise.getType().toReadable());
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Failed to disguise as a %s"),
|
||||
disguise.getType().toReadable()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -79,15 +83,13 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
ArrayList<String> tabs = new ArrayList<String>();
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
String[] args = getArgs(origArgs);
|
||||
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender);
|
||||
|
||||
if (args.length == 0) {
|
||||
for (String type : getAllowedDisguises(perms)) {
|
||||
tabs.add(type);
|
||||
}
|
||||
tabs.addAll(getAllowedDisguises(perms));
|
||||
} else {
|
||||
DisguisePerm disguiseType = DisguiseParser.getDisguisePerm(args[0]);
|
||||
|
||||
@@ -100,7 +102,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
} else {
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? 2 : 1; i < args.length; i++) {
|
||||
@@ -160,18 +162,21 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
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));
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"));
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguise player " + "<Name>"));
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(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>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguise " + "<Dropped_Item/Falling_Block> <Id> <Durability>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user