mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-14 15:26:54 +01:00
Current work
This commit is contained in:
parent
f4bc7ef3a4
commit
cba8cb417c
@ -28,6 +28,9 @@ SaveDisguises:
|
||||
KeepDisguises:
|
||||
PlayerDeath: false
|
||||
|
||||
# Should the plugin use translations? Note that a player must see the message before it will appear in translations.yml
|
||||
Translations: false
|
||||
|
||||
# How should the plugin handle self disguises scoreboards?
|
||||
# MODIFY_SCOREBOARD - Modifies the player's current team if possible, otherwise assigns them to a new scoreboard team
|
||||
# IGNORE_SCOREBOARD - Doesn't touch scoreboards at all, effectively means that if you didn't disable pushing in their scoreboard team; They will still be pushed around
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -60,6 +61,7 @@ public class DisguiseConfig {
|
||||
private static boolean updatePlayerCache;
|
||||
private static boolean savePlayerDisguises;
|
||||
private static boolean saveEntityDisguises;
|
||||
private static boolean useTranslations;
|
||||
|
||||
public static Entry<String, Disguise> getCustomDisguise(String disguise) {
|
||||
for (Entry<String, Disguise> entry : customDisguises.entrySet()) {
|
||||
@ -77,6 +79,16 @@ public class DisguiseConfig {
|
||||
return savePlayerDisguises;
|
||||
}
|
||||
|
||||
public static boolean isUseTranslations() {
|
||||
return useTranslations;
|
||||
}
|
||||
|
||||
public static void setUseTranslations(boolean setUseTranslations) {
|
||||
useTranslations = setUseTranslations;
|
||||
|
||||
TranslateType.reloadTranslations();
|
||||
}
|
||||
|
||||
public static boolean isSaveEntityDisguises() {
|
||||
return saveEntityDisguises;
|
||||
}
|
||||
@ -180,6 +192,7 @@ public class DisguiseConfig {
|
||||
setUpdateGameProfiles(config.getBoolean("UpdateGameProfiles"));
|
||||
setSavePlayerDisguises(config.getBoolean("SaveDisguises.Players"));
|
||||
setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities"));
|
||||
setUseTranslations(config.getBoolean("Translations"));
|
||||
|
||||
try {
|
||||
String option = config.getString("SelfDisguisesScoreboard",
|
||||
|
@ -81,7 +81,7 @@ public class LibsDisguises extends JavaPlugin {
|
||||
|
||||
PacketsManager.addPacketListeners();
|
||||
|
||||
TranslateFiller.fillConfigs();
|
||||
TranslateType.MESSAGE.name(); // Call the static loader
|
||||
|
||||
listener = new DisguiseListener(this);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ public class DisguiseParser {
|
||||
super();
|
||||
}
|
||||
|
||||
public DisguiseParseException(String string) {
|
||||
super(string);
|
||||
public DisguiseParseException(LibsMessages message, String... params) {
|
||||
super(message.get(params));
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,11 +467,12 @@ public class DisguiseParser {
|
||||
public static Disguise parseDisguise(CommandSender sender, String permNode, String[] args,
|
||||
HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> permissionMap) throws DisguiseParseException, IllegalAccessException, InvocationTargetException {
|
||||
if (permissionMap.isEmpty()) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "You are forbidden to use this command.");
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use this " + "command."));
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
throw new DisguiseParseException("No arguments defined");
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get("No arguments defined"));
|
||||
}
|
||||
|
||||
// How many args to skip due to the disugise being constructed
|
||||
@ -487,15 +488,17 @@ public class DisguiseParser {
|
||||
disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase());
|
||||
|
||||
if (disguise == null) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Cannot find a disguise under the reference " + args[0]);
|
||||
throw new DisguiseParseException(String.format(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Cannot find a disguise under the reference %s"),
|
||||
args[0]));
|
||||
}
|
||||
} else {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "You do not have perimssion to use disguise references!");
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "You do not have perimssion to use disguise references!"));
|
||||
}
|
||||
|
||||
optionPermissions = (permissionMap.containsKey(disguise.getType()) ? permissionMap.get(disguise.getType()) :
|
||||
optionPermissions = (permissionMap.containsKey(new DisguisePerm(disguise.getType())) ?
|
||||
permissionMap.get(new DisguisePerm(disguise.getType())) :
|
||||
new HashMap<ArrayList<String>, Boolean>());
|
||||
} else {
|
||||
DisguisePerm disguisePerm = getDisguisePerm(args[0]);
|
||||
@ -506,21 +509,24 @@ public class DisguiseParser {
|
||||
}
|
||||
|
||||
if (disguisePerm == null) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED + " doesn't exist!");
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + "%s" + ChatColor.RED + " " + "doesn't exist!"),
|
||||
args[0]));
|
||||
}
|
||||
|
||||
if (disguisePerm.isUnknown()) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!");
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You cannot disguise as " + ChatColor.GREEN + "Unknown!"));
|
||||
}
|
||||
|
||||
if (disguisePerm.getEntityType() == null) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! This disguise couldn't be loaded!");
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "Error! This disguise " + "couldn't be loaded!"));
|
||||
}
|
||||
|
||||
if (!permissionMap.containsKey(disguisePerm)) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "You are forbidden to use this disguise.");
|
||||
throw new DisguiseParseException(
|
||||
TranslateType.MESSAGE.get(ChatColor.RED + "You are forbidden to use " + "this disguise."));
|
||||
}
|
||||
|
||||
optionPermissions = permissionMap.get(disguisePerm);
|
||||
@ -532,12 +538,13 @@ public class DisguiseParser {
|
||||
// If he is doing a player disguise
|
||||
if (args.length == 1) {
|
||||
// He needs to give the player name
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! You need to give a player name!");
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You need " + "to give a player name!"));
|
||||
} else {
|
||||
if (!disguiseOptions.isEmpty() && (!disguiseOptions.containsKey(
|
||||
args[1].toLowerCase()) || !disguiseOptions.get(args[1].toLowerCase()))) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! You don't have permission to use that name!");
|
||||
throw new DisguiseParseException(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You don't have permission to use that name!"));
|
||||
}
|
||||
|
||||
args[1] = args[1].replace("\\_", " ");
|
||||
@ -604,8 +611,9 @@ public class DisguiseParser {
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! " + disguisePerm.toReadable() + " doesn't know what to do with " + args[1] + "!");
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! %s doesn't know" + " " + "what to do with %s!"),
|
||||
disguisePerm.toReadable(), args[1]));
|
||||
}
|
||||
toSkip++;
|
||||
// If they also defined a data value
|
||||
@ -615,8 +623,10 @@ public class DisguiseParser {
|
||||
}
|
||||
if (secondArg != null) {
|
||||
if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK && disguisePerm.getType() != DisguiseType.DROPPED_ITEM) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! Only the disguises " + DisguiseType.FALLING_BLOCK.toReadable() + " and " + DisguiseType.DROPPED_ITEM.toReadable() + " uses a second number!");
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! Only the disguises " + DisguiseType.FALLING_BLOCK.toReadable() + " and " + DisguiseType.DROPPED_ITEM.toReadable() + " uses a second number!"),
|
||||
DisguiseType.FALLING_BLOCK.toReadable(),
|
||||
DisguiseType.DROPPED_ITEM.toReadable()));
|
||||
}
|
||||
miscData = Integer.parseInt(secondArg);
|
||||
}
|
||||
@ -635,8 +645,9 @@ public class DisguiseParser {
|
||||
}
|
||||
|
||||
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
|
||||
throw new DisguiseParseException(
|
||||
ChatColor.RED + "Error! You do not have permission to use the parameter " + toCheck + " on the " + disguisePerm.toReadable() + " disguise!");
|
||||
throw new DisguiseParseException(String.format(TranslateType.MESSAGE.get(
|
||||
ChatColor.RED + "Error! You do not have permission to use the parameter %s on the" + " %s disguise!"),
|
||||
toCheck, disguisePerm.toReadable()));
|
||||
}
|
||||
}
|
||||
|
||||
|
22
src/me/libraryaddict/disguise/utilities/LibsMessages.java
Normal file
22
src/me/libraryaddict/disguise/utilities/LibsMessages.java
Normal file
@ -0,0 +1,22 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 15/06/2017.
|
||||
*/
|
||||
public enum LibsMessages {
|
||||
// Format being CLASS_STRING. So no perm = DISG_COMMAND_NO_PERM. Or DISG_PARSE_NO_PERM_OPTION
|
||||
TEST("This is a test string");
|
||||
|
||||
private String string;
|
||||
|
||||
LibsMessages(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String get(String... strings) {
|
||||
if (strings.length == 0)
|
||||
return TranslateType.MESSAGE.get(string);
|
||||
|
||||
return String.format(TranslateType.MESSAGE.get(string), (Object[]) strings);
|
||||
}
|
||||
}
|
@ -149,7 +149,7 @@ public class ReflectionFlagWatchers {
|
||||
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
||||
new ParamInfo(Villager.Profession.class, "Villager Profession",
|
||||
"View all the professions you can set on a villager");
|
||||
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 5), "Direction",
|
||||
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 4), "Direction",
|
||||
"View the five directions usable on player setSleeping disguise");
|
||||
new ParamInfo(Rabbit.Type.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
|
||||
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
|
||||
@ -178,7 +178,7 @@ public class ReflectionFlagWatchers {
|
||||
|
||||
new ParamInfo(ItemStack.class, "Item (id:damage)", "An ItemStack compromised of ID:Durability", materials);
|
||||
|
||||
new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..)", "Four ItemStacks seperated by an ,",
|
||||
new ParamInfo(ItemStack[].class, "Four ItemStacks (id:damage,id:damage..)", "Four ItemStacks separated by an ,",
|
||||
materials) {
|
||||
@Override
|
||||
public String[] getEnums(String tabComplete) {
|
||||
@ -203,14 +203,14 @@ public class ReflectionFlagWatchers {
|
||||
potionEnums.toArray(new String[0]));
|
||||
new ParamInfo(String.class, "Text", "A line of text");
|
||||
new ParamInfo(boolean.class, "True/False", "True or False", new String[]{"true", "false"});
|
||||
new ParamInfo(int.class, "Number", "A whole number, no decimcals");
|
||||
new ParamInfo(int.class, "Number", "A whole number, no decimals");
|
||||
new ParamInfo(double.class, "Number", "A number which can have decimals");
|
||||
new ParamInfo(float.class, "Number", "A number which can have decimals");
|
||||
|
||||
new ParamInfo(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse");
|
||||
new ParamInfo(int[].class, "number,number,number...", "Numbers seperated by an ,");
|
||||
new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,");
|
||||
|
||||
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers seperated by an ,");
|
||||
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers separated by a ,");
|
||||
new ParamInfo(GameProfile.class, "GameProfile",
|
||||
"Get the gameprofile here https://sessionserver.mojang.com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false");
|
||||
|
||||
@ -223,7 +223,7 @@ public class ReflectionFlagWatchers {
|
||||
}
|
||||
|
||||
public static Method[] getDisguiseWatcherMethods(Class<? extends FlagWatcher> watcherClass) {
|
||||
ArrayList<Method> methods = new ArrayList<Method>(Arrays.asList(watcherClass.getMethods()));
|
||||
ArrayList<Method> methods = new ArrayList<>(Arrays.asList(watcherClass.getMethods()));
|
||||
|
||||
Iterator<Method> itel = methods.iterator();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@ -15,8 +16,11 @@ public class TranslateFiller {
|
||||
if (!info.isEnums())
|
||||
continue;
|
||||
|
||||
if (info.getParamClass() == ItemStack.class || info.getParamClass() == ItemStack[].class)
|
||||
continue;
|
||||
|
||||
for (String e : info.getEnums("")) {
|
||||
TranslateType.METHOD_PARAM.get(e, "Name for the param for " + info.getName());
|
||||
TranslateType.METHOD_PARAM.get(e, "Used as a disguise option for " + info.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,10 +28,23 @@ public class TranslateFiller {
|
||||
type.toReadable();
|
||||
|
||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(type.getWatcherClass())) {
|
||||
Class para = method.getParameterTypes()[0];
|
||||
String className = method.getDeclaringClass().getSimpleName().replace("Watcher", "");
|
||||
|
||||
if (className.equals("Flag") || className.equals("Disguise"))
|
||||
className = "Entity";
|
||||
else if (className.equals("Living"))
|
||||
className = "Living Entity";
|
||||
else if (className.equals("AbstractHorse"))
|
||||
className = "Horse";
|
||||
else if (className.equals("DroppedItem"))
|
||||
className = "Item";
|
||||
else if (className.equals("IllagerWizard"))
|
||||
className = "Illager";
|
||||
|
||||
TranslateType.METHOD.get(method.getName(),
|
||||
"Found in " + method.getDeclaringClass().getSimpleName().replace("Watcher",
|
||||
"") + " and accepts as a parameter " + TranslateType.METHOD_PARAM.get(
|
||||
method.getParameterTypes()[0].getSimpleName()));
|
||||
"Found in the disguise options for " + className + " and uses " + (para.isArray() ?
|
||||
"multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -13,46 +17,80 @@ import java.util.Objects;
|
||||
* Created by libraryaddict on 10/06/2017.
|
||||
*/
|
||||
public enum TranslateType {
|
||||
DISGUISE("disguise_names"), MESSAGE("messages"), METHOD_PARAM("option_names"), METHOD("disguise_options");
|
||||
DISGUISE("disguises"), MESSAGE("messages"), METHOD_PARAM("disguise_options"), METHOD("disguise_option_parameters");
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
private HashMap<String, String> translated = new HashMap<>();
|
||||
|
||||
TranslateType(String fileName) {
|
||||
file = new File("translate", fileName + ".yml");
|
||||
file = new File("plugins/LibsDisguises/Translations", fileName + ".yml");
|
||||
reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
if (!file.exists())
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
try {
|
||||
file.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
public static void reloadTranslations() {
|
||||
for (TranslateType type : values()) {
|
||||
type.reload();
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
TranslateFiller.fillConfigs();
|
||||
}
|
||||
|
||||
private YamlConfiguration getConfig() {
|
||||
return config;
|
||||
private void reload() {
|
||||
if (!LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations())
|
||||
return;
|
||||
|
||||
translated.clear();
|
||||
|
||||
if (!file.exists())
|
||||
return;
|
||||
|
||||
System.out.println("[LibsDisguises] Loading translations: " + name());
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.options().pathSeparator(Character.toChars(0)[0]);
|
||||
|
||||
try {
|
||||
config.load(file);
|
||||
|
||||
for (String key : config.getKeys(false)) {
|
||||
String value = config.getString(key);
|
||||
|
||||
if (value == null)
|
||||
System.err.println("Translation for " + name() + " has a null value for the key '" + key + "'");
|
||||
else
|
||||
translated.put(key, value);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void save(String message, String comment) {
|
||||
message = StringEscapeUtils.escapeJson(message);
|
||||
|
||||
if (getConfig().contains(message))
|
||||
private void save(String message, String comment) {
|
||||
if (translated.containsKey(message))
|
||||
return;
|
||||
|
||||
translated.put(message, message);
|
||||
|
||||
message = StringEscapeUtils.escapeJava(message);
|
||||
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(getFile());
|
||||
writer.write((comment != null ? "# " + comment + "\n" : "") + message + ": " + message + "\n");
|
||||
boolean exists = file.exists();
|
||||
|
||||
if (!exists) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
FileWriter writer = new FileWriter(getFile(), true);
|
||||
|
||||
if (!exists)
|
||||
writer.write("# To use translations in Lib's Disguises, you must have the purchased plugin\n");
|
||||
|
||||
writer.write("\n" + (comment != null ? "# " + comment + "\n" :
|
||||
"") + "\"" + message + "\": \"" + message + "\"\n");
|
||||
|
||||
writer.close();
|
||||
}
|
||||
@ -62,10 +100,10 @@ public enum TranslateType {
|
||||
}
|
||||
|
||||
public String reverseGet(String translated) {
|
||||
translated = StringEscapeUtils.unescapeJson(translated).toLowerCase();
|
||||
translated = translated.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Object> entry : getConfig().getValues(false).entrySet()) {
|
||||
if (!Objects.equals(entry.getValue().toString().toLowerCase(), translated))
|
||||
for (Map.Entry<String, String> entry : this.translated.entrySet()) {
|
||||
if (!Objects.equals(entry.getValue().toLowerCase(), translated))
|
||||
continue;
|
||||
|
||||
return entry.getKey();
|
||||
@ -82,10 +120,15 @@ public enum TranslateType {
|
||||
}
|
||||
|
||||
public String get(String message, String comment) {
|
||||
String msg = getConfig().getString(StringEscapeUtils.escapeJson(message));
|
||||
if (!LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations())
|
||||
return message;
|
||||
System.out.println("1");
|
||||
|
||||
String msg = translated.get(message);
|
||||
|
||||
if (msg != null)
|
||||
return msg;
|
||||
System.out.println("2");
|
||||
|
||||
save(message, comment);
|
||||
|
||||
|
@ -13,7 +13,6 @@ public class SerializerGameProfile implements JsonSerializer<WrappedGameProfile>
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(WrappedGameProfile src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
System.out.println(src.getHandle().toString());
|
||||
return context.serialize(src.getHandle(), GameProfile.class);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user