Current work
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -12,16 +13,16 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
@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!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,43 +38,37 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
|
||||
for (int i = player == null ? 0 : 1; i < args.length; i++) {
|
||||
String option = args[i];
|
||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip")
|
||||
|| StringUtils.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils.startsWithIgnoreCase(option,
|
||||
"ignoreEnquip")) {
|
||||
doEquipment = false;
|
||||
}
|
||||
else if (option.equalsIgnoreCase("doSneakSprint")) {
|
||||
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
||||
doSneak = true;
|
||||
doSprint = true;
|
||||
}
|
||||
else if (option.equalsIgnoreCase("doSneak")) {
|
||||
} else if (option.equalsIgnoreCase("doSneak")) {
|
||||
doSneak = true;
|
||||
}
|
||||
else if (option.equalsIgnoreCase("doSprint")) {
|
||||
} else if (option.equalsIgnoreCase("doSprint")) {
|
||||
doSprint = true;
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Unknown option '" + option
|
||||
+ "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'");
|
||||
} else {
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_RED + "Unknown " + "option '%s" + "' - Valid options are 'IgnoreEquipment' 'DoSneakSprint' 'DoSneak' 'DoSprint'"),
|
||||
option));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean[] options = new Boolean[] {
|
||||
doEquipment, doSneak, doSprint
|
||||
};
|
||||
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
||||
|
||||
if (player != null) {
|
||||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
LibsDisguises.getInstance().getListener().setDisguiseClone(sender.getName(), options);
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire()
|
||||
+ " seconds to grab the disguise reference!");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Right click a entity in the next %s" + " seconds to grab the disguise reference!"),
|
||||
DisguiseConfig.getDisguiseCloneExpire()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -81,7 +76,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
|
||||
@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);
|
||||
|
||||
@@ -103,12 +98,13 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN
|
||||
+ "Right click a entity to get a disguise reference you can pass to other disguise commands!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN
|
||||
+ "Security note: Any references you create will be available to all players able to use disguise references.");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN
|
||||
+ "Optional" + ChatColor.DARK_GREEN + ")");
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "Right click a entity to get a disguise reference you can pass to other " + "disguise commands!"));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "Security note: Any references you create will be available to all players " + "able to use disguise references."));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
@@ -23,17 +9,32 @@ 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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (getPermissions(sender).isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,14 +62,14 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise);
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire()
|
||||
+ " seconds to disguise it as a " + disguise.getType().toReadable() + "!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire() + " " + "seconds to disguise it as a " + disguise.getType().toReadable() + "!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
ArrayList<String> tabs = new ArrayList<String>();
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return tabs;
|
||||
@@ -82,8 +83,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (String type : getAllowedDisguises(perms)) {
|
||||
tabs.add(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DisguisePerm disguiseType = DisguiseParser.getDisguisePerm(args[0]);
|
||||
|
||||
if (disguiseType == null)
|
||||
@@ -93,9 +93,8 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
} else {
|
||||
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++) {
|
||||
@@ -124,8 +123,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -137,7 +135,8 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
disguiseType.getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -155,22 +154,25 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
||||
* @param map
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
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 then right click a entity to disguise it!");
|
||||
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 then right click an entity to disguise it!"));
|
||||
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 + "/disguiseentity player <Name>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguiseentity player <Name>"));
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>"));
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> " + "<Durability>"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,31 +1,29 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
||||
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.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (String node : new String[] {
|
||||
"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"
|
||||
}) {
|
||||
for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) {
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permMap = DisguiseParser.getPermissions(sender,
|
||||
"libsdisguises." + node + ".");
|
||||
|
||||
@@ -33,8 +31,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
if (args.length == 0) {
|
||||
sendCommandUsage(sender, null);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ParamInfo help = null;
|
||||
|
||||
for (ParamInfo s : ReflectionFlagWatchers.getParamInfos()) {
|
||||
@@ -47,20 +44,28 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
}
|
||||
|
||||
if (help != null) {
|
||||
sender.sendMessage(ChatColor.RED + help.getName() + ": " + ChatColor.GREEN
|
||||
+ StringUtils.join(help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
if (help.isEnums()) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + StringUtils.join(
|
||||
help.getEnums(""), ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + help.getName() + ": " + ChatColor.GREEN + help.getDescription());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]);
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the disguise ") + args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!permMap.containsKey(type)) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You do not have permission for " + "that disguise!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -80,8 +85,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!key.contains(method.getName().toLowerCase())) {
|
||||
} else if (!key.contains(method.getName().toLowerCase())) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
@@ -105,13 +109,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
|
||||
if (declaring == LivingWatcher.class) {
|
||||
methodColor = ChatColor.AQUA;
|
||||
}
|
||||
else if (!(FlagWatcher.class.isAssignableFrom(declaring)) || declaring == FlagWatcher.class) {
|
||||
} else if (!(FlagWatcher.class.isAssignableFrom(
|
||||
declaring)) || declaring == FlagWatcher.class) {
|
||||
methodColor = ChatColor.GRAY;
|
||||
}
|
||||
|
||||
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName()
|
||||
+ ChatColor.DARK_RED + ")";
|
||||
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
||||
|
||||
map.put(str, methodColor);
|
||||
methods.add(str);
|
||||
@@ -131,12 +134,13 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
methods.add(ChatColor.RED + "No options with permission to use");
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + " options: "
|
||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + TranslateType.MESSAGE.get(
|
||||
" options: ") + StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
|
||||
if (ignored > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Ignored " + ignored
|
||||
+ " options you do not have permission to use. Add 'show' to view unusable options.");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Ignored %s" + " options you do not have permission to use. Add " + "'show' to view unusable options."),
|
||||
ignored));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -144,18 +148,16 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
for (String node : new String[] {
|
||||
"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"
|
||||
}) {
|
||||
for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) {
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser.getPermissions(sender,
|
||||
"libsdisguises." + node + ".");
|
||||
|
||||
@@ -170,8 +172,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
for (ParamInfo s : ReflectionFlagWatchers.getParamInfos()) {
|
||||
tabs.add(s.getName().replaceAll(" ", ""));
|
||||
}
|
||||
}
|
||||
else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
||||
} else if (DisguiseParser.getDisguisePerm(args[0]) == null) {
|
||||
tabs.add("Show");
|
||||
}
|
||||
}
|
||||
@@ -183,13 +184,14 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
sender.sendMessage(ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN
|
||||
+ "- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission to use");
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN + "- View the options you can set " + "on a disguise. Add 'show' to reveal the options you don't have permission to use"));
|
||||
|
||||
for (ParamInfo s : ReflectionFlagWatchers.getParamInfos()) {
|
||||
sender.sendMessage(ChatColor.RED + "/disguisehelp " + s.getName().replaceAll(" ", "") + ChatColor.GREEN + " - "
|
||||
+ s.getDescription());
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "/disguisehelp " + s.getName().replaceAll(" ",
|
||||
"") + ChatColor.GREEN + " - " + s.getDescription()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@@ -22,19 +8,34 @@ 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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseModifyCommand 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;
|
||||
}
|
||||
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||
|
||||
if (map.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,18 +47,18 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not disguised!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are not disguised!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!map.containsKey(new DisguisePerm(disguise.getType()))) {
|
||||
sender.sendMessage(ChatColor.RED + "No permission to modify your disguise!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "No permission to modify your disguise!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, getPermissions(sender).get(new DisguisePerm(disguise.getType())),
|
||||
new ArrayList<String>(), args);
|
||||
DisguiseParser.callMethods(sender, disguise,
|
||||
getPermissions(sender).get(new DisguisePerm(disguise.getType())), new ArrayList<String>(), args);
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
@@ -71,14 +72,14 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Your disguise has been modified!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Your disguise has been modified!"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
ArrayList<String> tabs = new ArrayList<String>();
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
return tabs;
|
||||
@@ -94,7 +95,7 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
||||
|
||||
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++) {
|
||||
@@ -123,8 +124,7 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -149,11 +149,15 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Modify your own disguise as you wear it!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguisemodify setBaby true setSprinting true");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can modify the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Modify your own disguise as you wear " + "it!"));
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "/disguisemodify setBaby true setSprinting true"));
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
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;
|
||||
@@ -13,22 +14,22 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (getPermissions(sender).isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,14 +40,15 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
||||
|
||||
LibsDisguises.getInstance().getListener().setDisguiseModify(sender.getName(), args);
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Right click a disguised entity in the next "
|
||||
+ DisguiseConfig.getDisguiseEntityExpire() + " seconds to modify their disguise!");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Right click a disguised entity " + "in the next %s seconds to modify their disguise!"),
|
||||
DisguiseConfig.getDisguiseEntityExpire()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
ArrayList<String> tabs = new ArrayList<String>();
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return tabs;
|
||||
@@ -75,8 +77,7 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -88,7 +89,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(perm.getType().getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
perm.getType().getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -104,12 +106,14 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
||||
* @param map
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Choose the options for a disguise then right click a entity to modify it!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can modify the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "Choose the options for a disguise then right click a entity to modify it!"));
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
||||
@@ -20,6 +7,19 @@ 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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||
|
||||
if (map.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s" + "'"),
|
||||
args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,18 +63,21 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
disguise = DisguiseAPI.getDisguise(player);
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(ChatColor.RED + "The player '" + player.getName() + "' is not disguised");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "The player '%s' is " + "not disguised"),
|
||||
player.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!map.containsKey(new DisguisePerm(disguise.getType()))) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to modify this disguise");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You do not have permission to modify this " + "disguise"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, map.get(new DisguisePerm(disguise.getType())), new ArrayList<String>(),
|
||||
newArgs);
|
||||
DisguiseParser.callMethods(sender, disguise, map.get(new DisguisePerm(disguise.getType())),
|
||||
new ArrayList<String>(), newArgs);
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
@@ -86,14 +91,15 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Modified the disguise of " + player.getName() + "!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Modified the disguise of " + player.getName() + "!"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -105,12 +111,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s'"),
|
||||
args[0]));
|
||||
return tabs;
|
||||
}
|
||||
|
||||
@@ -123,13 +130,15 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
disguise = DisguiseAPI.getDisguise(player);
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(ChatColor.RED + "The player '" + player.getName() + "' is not disguised");
|
||||
sender.sendMessage(String.format(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "The player '%s' " + "is not disguised"),
|
||||
player.getName()));
|
||||
return tabs;
|
||||
}
|
||||
|
||||
DisguisePerm disguiseType = new DisguisePerm(disguise.getType());
|
||||
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
@@ -158,8 +167,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(p.getName());
|
||||
@@ -171,7 +179,8 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
disguiseType.getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -185,11 +194,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Modify the disguise of another player!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can modify the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "Modify the disguise of another player!"));
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the " + "disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,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;
|
||||
@@ -42,8 +43,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
|
||||
if (sender instanceof Player) {
|
||||
center = ((Player) sender).getLocation();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
}
|
||||
|
||||
@@ -53,14 +53,15 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
@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!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||
|
||||
if (map.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,8 +79,10 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "EntityTypes usable are: " + ChatColor.GREEN
|
||||
+ StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + ".");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "EntityTypes usable " + "are: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(classes,
|
||||
ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + "."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,31 +107,36 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Unrecognised EntityType " + args[0]);
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Unrecognised " + "EntityType %s"),
|
||||
args[0]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply the disguise options as well as the radius"
|
||||
+ (starting != 0 ? " and EntityType" : ""));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You need to supply the disguise options as well as the radius" + (starting != 0 ?
|
||||
" and EntityType" : "")));
|
||||
return true;
|
||||
}
|
||||
else if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a radius as well as the disguise options");
|
||||
} else if (args.length < 2) {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You need to supply a radius as well as " + "the disguise options"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isNumeric(args[starting])) {
|
||||
sender.sendMessage(ChatColor.RED + args[starting] + " is not a number");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(ChatColor.RED + "%s is not a " + "number"),
|
||||
args[starting]));
|
||||
return true;
|
||||
}
|
||||
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius));
|
||||
radius = maxRadius;
|
||||
}
|
||||
|
||||
@@ -184,14 +192,16 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
|
||||
if (noPermission > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "No permission to modify " + noPermission + " disguises!");
|
||||
sender.sendMessage(String.format(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "No permission to modify " + "%s disguises!"),
|
||||
noPermission));
|
||||
}
|
||||
|
||||
if (modifiedDisguises > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Successfully modified the disguises of " + modifiedDisguises + " entities!");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find any disguised entities!");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Successfully modified the disguises of %s" + " entities!"), modifiedDisguises));
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Couldn't find any disguised entities!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -199,7 +209,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
|
||||
@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);
|
||||
@@ -231,11 +241,12 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius));
|
||||
radius = maxRadius;
|
||||
}
|
||||
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
|
||||
for (Entity entity : getNearbyEntities(sender, radius)) {
|
||||
Disguise disguise = DisguiseAPI.getDisguise(entity);
|
||||
@@ -246,9 +257,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
DisguiseType disguiseType = disguise.getType();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
|
||||
for (String arg : args) {
|
||||
if (!method.getName().equalsIgnoreCase(arg))
|
||||
continue;
|
||||
|
||||
@@ -256,7 +265,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
}
|
||||
}
|
||||
|
||||
if (passesCheck(sender, perms.get(disguiseType), usedOptions)) {
|
||||
if (passesCheck(sender, perms.get(new DisguisePerm(disguiseType)), usedOptions)) {
|
||||
boolean addMethods = true;
|
||||
|
||||
if (args.length > 1 + starting) {
|
||||
@@ -272,8 +281,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -285,7 +293,8 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
disguiseType.getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -299,31 +308,35 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Modify the disguises in a radius! Caps at " + maxRadius + " blocks!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can modify the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "Modify the disguises in a radius! Caps at %s blocks!"), maxRadius));
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can modify the disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
|
||||
String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")";
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>")
|
||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
}
|
||||
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby"
|
||||
+ optional + ">").replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional
|
||||
+ "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">")
|
||||
.replace("<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,5 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
@@ -23,6 +10,20 @@ 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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
|
||||
@@ -31,7 +32,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||
|
||||
if (map.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,14 +42,16 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the player");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You need to supply a disguise as well as " + "the player"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find the player '%s'"), args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,8 +81,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Can't disguise a living entity as a misc disguise. This has been disabled in the" + " config!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,12 +100,13 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
DisguiseAPI.disguiseToAll(player, disguise);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
||||
+ disguise.getType().toReadable() + "!");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Failed to disguise " + player.getName() + " as a " + disguise.getType().toReadable() + "!");
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully disguised %s as a %s!"),
|
||||
player.getName(), disguise.getType().toReadable()));
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Failed to disguise %s as a %s!"),
|
||||
player.getName(), disguise.getType().toReadable()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -110,7 +114,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
@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);
|
||||
@@ -119,13 +123,9 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
}
|
||||
else if (args.length == 1) {
|
||||
for (String type : getAllowedDisguises(perms)) {
|
||||
tabs.add(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (args.length == 1) {
|
||||
tabs.addAll(getAllowedDisguises(perms));
|
||||
} else {
|
||||
DisguisePerm disguiseType = DisguiseParser.getDisguisePerm(args[1]);
|
||||
|
||||
if (disguiseType == null)
|
||||
@@ -135,9 +135,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
} else {
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? 3 : 2; i < args.length; i++) {
|
||||
@@ -163,11 +162,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
addMethods = false;
|
||||
|
||||
if (info.isEnums()) {
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tabs.addAll(Arrays.asList(info.getEnums(origArgs[origArgs.length - 1])));
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
tabs.add(player.getName());
|
||||
@@ -179,7 +175,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(
|
||||
disguiseType.getWatcherClass())) {
|
||||
tabs.add(method.getName());
|
||||
}
|
||||
}
|
||||
@@ -194,22 +191,26 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
protected void sendCommandUsage(CommandSender sender,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
|
||||
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
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 + "/disguiseplayer <PlayerName> player <Name>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player " + "<Name>"));
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> " + "<DisguiseType> <Baby>"));
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> " + "<Durability>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,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;
|
||||
@@ -25,10 +26,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private int maxRadius = 30;
|
||||
@@ -46,14 +44,15 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
@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!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender);
|
||||
|
||||
if (map.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -72,8 +71,9 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "EntityTypes usable are: " + ChatColor.GREEN + StringUtils.join(classes,
|
||||
ChatColor.DARK_GREEN + ", " + ChatColor.GREEN) + ChatColor.DARK_GREEN + ".");
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "EntityTypes usable are: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(classes,
|
||||
ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,35 +94,40 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
try {
|
||||
type = EntityType.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Unrecognised EntityType " + args[0]);
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Unrecognised " + "EntityType %s"),
|
||||
args[0]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a disguise as well as the radius" + (starting != 0 ?
|
||||
" and EntityType" : ""));
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You need to supply a disguise as well as the radius" + (starting != 0 ?
|
||||
" and EntityType" : "")));
|
||||
return true;
|
||||
} else if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "You need to supply a radius as well as the disguise");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You need to supply a radius as well as " + "the disguise"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isNumeric(args[starting])) {
|
||||
sender.sendMessage(ChatColor.RED + args[starting] + " is not a number");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "%s is not a number"), args[starting]));
|
||||
return true;
|
||||
}
|
||||
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Limited radius to %s! Don't want to make too much lag right?"), maxRadius));
|
||||
radius = maxRadius;
|
||||
}
|
||||
|
||||
@@ -193,14 +198,17 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (disguisedEntitys > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully disguised %s" + " entities!"),
|
||||
disguisedEntitys));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find any entities to disguise!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Couldn't find any entities to disguise!"));
|
||||
}
|
||||
|
||||
if (miscDisguises > 0) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Failed to disguise " + miscDisguises + " entities because the option to disguise a living entity as a non-living has been disabled in the config");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Failed to disguise %s entities because the option to disguise a living entity as" + " a non-living has been disabled in the config"),
|
||||
miscDisguises));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -208,7 +216,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
|
||||
@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);
|
||||
@@ -238,9 +246,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
|
||||
if (args.length == starting) {
|
||||
for (String type : getAllowedDisguises(perms)) {
|
||||
tabs.add(type);
|
||||
}
|
||||
tabs.addAll(getAllowedDisguises(perms));
|
||||
} else {
|
||||
|
||||
DisguisePerm disguiseType = DisguiseParser.getDisguisePerm(args[starting]);
|
||||
@@ -253,7 +259,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
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 ? starting + 2 :
|
||||
@@ -280,9 +286,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
addMethods = false;
|
||||
|
||||
if (info.isEnums()) {
|
||||
for (String e : info.getEnums(origArgs[origArgs.length - 1])) {
|
||||
tabs.add(e);
|
||||
}
|
||||
tabs.addAll(Arrays.asList(info.getEnums(origArgs[origArgs.length - 1])));
|
||||
} else {
|
||||
if (info.getParamClass() == String.class) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
@@ -315,30 +319,31 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
|
||||
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at %s blocks!"), maxRadius));
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "Disguise all entities in a radius! Caps at " + maxRadius + " blocks!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN + StringUtils.join(
|
||||
allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.DARK_GREEN + "You can use the " + "disguises: %s"),
|
||||
ChatColor.GREEN + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)));
|
||||
|
||||
String optional = ChatColor.DARK_GREEN + "(" + ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")";
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage(
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> player <Name>").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <DisguiseType> <Baby" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
(ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace(
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
|
||||
"<", "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")));
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius EntityTypes");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN + "/disguiseradius " + "EntityTypes"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -16,7 +17,8 @@ public class DisguiseViewSelfCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -24,14 +26,12 @@ public class DisguiseViewSelfCommand implements CommandExecutor {
|
||||
|
||||
if (DisguiseAPI.isViewSelfToggled(player)) {
|
||||
DisguiseAPI.setViewDisguiseToggled(player, false);
|
||||
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise off!");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "Toggled viewing own disguise off!"));
|
||||
} else {
|
||||
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||
sender.sendMessage(ChatColor.GREEN + "Toggled viewing own disguise on!");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "Toggled viewing own disguise on!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -12,7 +10,9 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
@@ -52,29 +52,28 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v"
|
||||
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
|
||||
+ " by libraryaddict, formerly maintained by Byteflux and NavidK0.\n" + "Use " + ChatColor.GREEN
|
||||
+ "/libsdisguises reload" + ChatColor.DARK_GREEN
|
||||
+ " to reload the config. All disguises will be blown by doing this.");
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + Bukkit.getPluginManager().getPlugin(
|
||||
"LibsDisguises").getDescription().getVersion() + " by libraryaddict, formerly maintained " + "by Byteflux and NavidK0." + (
|
||||
sender.hasPermission("libsdisguises.reload") ?
|
||||
"\nUse " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + "." :
|
||||
""));
|
||||
|
||||
if (LibsPremium.isPremium()) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "This server supports the plugin developer!");
|
||||
}
|
||||
}
|
||||
else if (args.length > 0) {
|
||||
} else if (args.length > 0) {
|
||||
if (sender.hasPermission("libsdisguises.reload")) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
LibsDisguises.getInstance().reload();
|
||||
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.GREEN + "[LibsDisguises] Reloaded config."));
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "[LibsDisguises] Did you mean 'reload'?"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -82,7 +81,7 @@ public class LibsDisguisesCommand implements CommandExecutor, 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);
|
||||
|
||||
if (args.length == 0)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -9,32 +10,24 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
|
||||
public class UndisguiseCommand implements CommandExecutor
|
||||
{
|
||||
public class UndisguiseCommand implements CommandExecutor {
|
||||
|
||||
@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!");
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the " + "console!"));
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("libsdisguises.undisguise"))
|
||||
{
|
||||
if (DisguiseAPI.isDisguised((Entity) sender))
|
||||
{
|
||||
if (sender.hasPermission("libsdisguises.undisguise")) {
|
||||
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
||||
DisguiseAPI.undisguiseToAll((Player) sender);
|
||||
sender.sendMessage(ChatColor.RED + "You are no longer disguised");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are no longer disguised"));
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are not disguised!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are not disguised!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,31 +1,27 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
|
||||
public class UndisguiseEntityCommand implements CommandExecutor
|
||||
{
|
||||
public class UndisguiseEntityCommand implements CommandExecutor {
|
||||
|
||||
@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!");
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!"));
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("libsdisguises.undisguiseentity"))
|
||||
{
|
||||
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
|
||||
LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), null);
|
||||
sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!");
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Right click a disguised entity to " + "undisguise them!"));
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,9 +1,7 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -12,7 +10,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
@@ -35,7 +35,7 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
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];
|
||||
@@ -57,29 +57,26 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
if (p != null) {
|
||||
if (DisguiseAPI.isDisguised(p)) {
|
||||
DisguiseAPI.undisguiseToAll(p);
|
||||
sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "The player is not disguised!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "The player is no longer disguised"));
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "The player is not disguised!"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "Player not found"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "Player not found");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "/undisguiseplayer <Name>"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
if (args.length != 0)
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -7,8 +9,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
|
||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
private int maxRadius = 30;
|
||||
|
||||
@@ -29,24 +29,28 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
@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!");
|
||||
sender.sendMessage(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You may not use this command from the console!"));
|
||||
return true;
|
||||
}
|
||||
if (sender.hasPermission("libsdisguises.undisguiseradius")) {
|
||||
int radius = maxRadius;
|
||||
if (args.length > 0) {
|
||||
if (!isNumeric(args[0])) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Error! " + ChatColor.GREEN + args[0] + ChatColor.RED + " is not a number!");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! " + ChatColor.GREEN + "%s" + ChatColor.RED + " is not a " + "number!"),
|
||||
args[0]));
|
||||
return true;
|
||||
}
|
||||
radius = Integer.parseInt(args[0]);
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||
sender.sendMessage(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Limited radius to %s" + "! Don't want to make too much lag right?"),
|
||||
maxRadius));
|
||||
radius = maxRadius;
|
||||
}
|
||||
}
|
||||
|
||||
int disguisedEntitys = 0;
|
||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||
if (entity == sender) {
|
||||
@@ -57,10 +61,11 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
disguisedEntitys++;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
sender.sendMessage(
|
||||
String.format(TranslateType.MESSAGE.get(ChatColor.RED + "Successfully undisguised %s entities!"),
|
||||
disguisedEntitys));
|
||||
} else {
|
||||
sender.sendMessage(TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this command."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user