Minor cleanup and untested disguise modify commands
This commit is contained in:
		
							
								
								
									
										16
									
								
								plugin.yml
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								plugin.yml
									
									
									
									
									
								
							| @@ -53,6 +53,22 @@ commands: | |||||||
|       aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd] |       aliases: [dviewself, dvs, disguisevs, disvs, vsd, viewselfdisguise, viewselfd] | ||||||
|       permission: libsdisguises.seecmd.viewself |       permission: libsdisguises.seecmd.viewself | ||||||
|       description: Toggle seeing your own disguise on or off. |       description: Toggle seeing your own disguise on or off. | ||||||
|  |     disguisemodify: | ||||||
|  |       aliases: [dmodify] | ||||||
|  |       permission: libsdisguises.seecmd.disguisemodify | ||||||
|  |       description: Modify your own disguise | ||||||
|  |     disguisemodifyplayer: | ||||||
|  |       aliases: [dmodifyplayer] | ||||||
|  |       permission: libsdisguises.seecmd.disguisemodifyplayer | ||||||
|  |       description: Modify the disguise of a player | ||||||
|  |     disguisemodifyradius: | ||||||
|  |       aliases: [dmodifyradius] | ||||||
|  |       permission: libsdisguises.seecmd.disguisemodifyradius | ||||||
|  |       description: Modify disguises in a radius | ||||||
|  |     disguisemodifyentity: | ||||||
|  |       aliases: [dmodifyentity] | ||||||
|  |       permission: libsdisguises.seecmd.disguisemodifyentity | ||||||
|  |       description: Modify a disguise by right clicking them | ||||||
|  |  | ||||||
| permissions: | permissions: | ||||||
|     libsdisguises.reload: |     libsdisguises.reload: | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package me.libraryaddict.disguise; | package me.libraryaddict.disguise; | ||||||
|  |  | ||||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||||
|  | import java.util.ArrayList; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| @@ -41,6 +42,9 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType; | |||||||
| import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; | import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; | ||||||
| import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; | import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; | ||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | ||||||
|  | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
|  | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
|  | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||||
| import me.libraryaddict.disguise.utilities.ReflectionManager; | import me.libraryaddict.disguise.utilities.ReflectionManager; | ||||||
| import me.libraryaddict.disguise.utilities.UpdateChecker; | import me.libraryaddict.disguise.utilities.UpdateChecker; | ||||||
| @@ -50,6 +54,7 @@ public class DisguiseListener implements Listener { | |||||||
|     private String currentVersion; |     private String currentVersion; | ||||||
|     private HashMap<String, Boolean[]> disguiseClone = new HashMap<>(); |     private HashMap<String, Boolean[]> disguiseClone = new HashMap<>(); | ||||||
|     private HashMap<String, Disguise> disguiseEntity = new HashMap<>(); |     private HashMap<String, Disguise> disguiseEntity = new HashMap<>(); | ||||||
|  |     private HashMap<String, String[]> disguiseModify = new HashMap<>(); | ||||||
|     private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>(); |     private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<>(); | ||||||
|     private String latestVersion; |     private String latestVersion; | ||||||
|     private LibsDisguises plugin; |     private LibsDisguises plugin; | ||||||
| @@ -310,79 +315,113 @@ public class DisguiseListener implements Listener { | |||||||
|  |  | ||||||
|     @EventHandler |     @EventHandler | ||||||
|     public void onRightClick(PlayerInteractEntityEvent event) { |     public void onRightClick(PlayerInteractEntityEvent event) { | ||||||
|         if (disguiseEntity.containsKey(event.getPlayer().getName()) || disguiseClone.containsKey(event.getPlayer().getName())) { |         if (!disguiseEntity.containsKey(event.getPlayer().getName()) && !disguiseClone.containsKey(event.getPlayer().getName())) { | ||||||
|             Player p = event.getPlayer(); |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|             event.setCancelled(true); |         Player p = event.getPlayer(); | ||||||
|             disguiseRunnable.remove(p.getName()).cancel(); |  | ||||||
|  |  | ||||||
|             Entity entity = event.getRightClicked(); |         event.setCancelled(true); | ||||||
|             String entityName; |         disguiseRunnable.remove(p.getName()).cancel(); | ||||||
|  |  | ||||||
|             if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) { |         Entity entity = event.getRightClicked(); | ||||||
|                 entityName = entity.getName(); |         String entityName; | ||||||
|             } |  | ||||||
|             else { |  | ||||||
|                 entityName = DisguiseType.getType(entity).toReadable(); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (disguiseClone.containsKey(p.getName())) { |         if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) { | ||||||
|                 Boolean[] options = disguiseClone.remove(p.getName()); |             entityName = entity.getName(); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             entityName = DisguiseType.getType(entity).toReadable(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|                 DisguiseUtilities.createClonedDisguise(p, entity, options); |         if (disguiseClone.containsKey(p.getName())) { | ||||||
|             } |             Boolean[] options = disguiseClone.remove(p.getName()); | ||||||
|             else if (disguiseEntity.containsKey(p.getName())) { |  | ||||||
|                 Disguise disguise = disguiseEntity.remove(p.getName()); |  | ||||||
|  |  | ||||||
|                 if (disguise != null) { |             DisguiseUtilities.createClonedDisguise(p, entity, options); | ||||||
|                     if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() |         } | ||||||
|                             && entity instanceof LivingEntity) { |         else if (disguiseEntity.containsKey(p.getName())) { | ||||||
|                         p.sendMessage(ChatColor.RED |             Disguise disguise = disguiseEntity.remove(p.getName()); | ||||||
|                                 + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!"); |  | ||||||
|                     } |  | ||||||
|                     else { |  | ||||||
|                         if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { |  | ||||||
|                             if (disguise.getWatcher() instanceof LivingWatcher) { |  | ||||||
|                                 disguise.getWatcher().setCustomName(((Player) entity).getDisplayName()); |  | ||||||
|  |  | ||||||
|                                 if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { |             if (disguise != null) { | ||||||
|                                     disguise.getWatcher().setCustomNameVisible(true); |                 if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() | ||||||
|                                 } |                         && entity instanceof LivingEntity) { | ||||||
|                             } |                     p.sendMessage(ChatColor.RED | ||||||
|                         } |                             + "Can't disguise a living entity as a misc disguise. This has been disabled in the config!"); | ||||||
|  |  | ||||||
|                         DisguiseAPI.disguiseToAll(entity, disguise); |  | ||||||
|  |  | ||||||
|                         String disguiseName = "a "; |  | ||||||
|  |  | ||||||
|                         if (disguise instanceof PlayerDisguise) { |  | ||||||
|                             disguiseName = "the player " + ((PlayerDisguise) disguise).getName(); |  | ||||||
|                         } |  | ||||||
|                         else { |  | ||||||
|                             disguiseName += disguise.getType().toReadable(); |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|                         if (disguise.isDisguiseInUse()) { |  | ||||||
|                             p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : "the ") + entityName |  | ||||||
|                                     + " as " + disguiseName + "!"); |  | ||||||
|                         } |  | ||||||
|                         else { |  | ||||||
|                             p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ") |  | ||||||
|                                     + entityName + " as " + disguiseName + "!"); |  | ||||||
|                         } |  | ||||||
|                     } |  | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|                     if (DisguiseAPI.isDisguised(entity)) { |                     if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { | ||||||
|                         DisguiseAPI.undisguiseToAll(entity); |                         if (disguise.getWatcher() instanceof LivingWatcher) { | ||||||
|  |                             disguise.getWatcher().setCustomName(((Player) entity).getDisplayName()); | ||||||
|  |  | ||||||
|                         p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName); |                             if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { | ||||||
|  |                                 disguise.getWatcher().setCustomNameVisible(true); | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     DisguiseAPI.disguiseToAll(entity, disguise); | ||||||
|  |  | ||||||
|  |                     String disguiseName = "a "; | ||||||
|  |  | ||||||
|  |                     if (disguise instanceof PlayerDisguise) { | ||||||
|  |                         disguiseName = "the player " + ((PlayerDisguise) disguise).getName(); | ||||||
|                     } |                     } | ||||||
|                     else { |                     else { | ||||||
|                         p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!"); |                         disguiseName += disguise.getType().toReadable(); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|  |                     if (disguise.isDisguiseInUse()) { | ||||||
|  |                         p.sendMessage(ChatColor.RED + "Disguised " + (entity instanceof Player ? "" : "the ") + entityName | ||||||
|  |                                 + " as " + disguiseName + "!"); | ||||||
|  |                     } | ||||||
|  |                     else { | ||||||
|  |                         p.sendMessage(ChatColor.RED + "Failed to disguise " + (entity instanceof Player ? "" : "the ") | ||||||
|  |                                 + entityName + " as " + disguiseName + "!"); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             else { | ||||||
|  |                 if (DisguiseAPI.isDisguised(entity)) { | ||||||
|  |                     DisguiseAPI.undisguiseToAll(entity); | ||||||
|  |  | ||||||
|  |                     p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName); | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         else if (disguiseModify.containsKey(p.getName())) { | ||||||
|  |             String[] options = disguiseModify.remove(p.getName()); | ||||||
|  |  | ||||||
|  |             Disguise disguise = DisguiseAPI.getDisguise(p, entity); | ||||||
|  |  | ||||||
|  |             if (disguise == null) { | ||||||
|  |                 p.sendMessage(ChatColor.RED + entityName + " is not disguised!"); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = DisguiseParser.getPermissions(p, | ||||||
|  |                     "libsdisguises.disguiseentitymodify."); | ||||||
|  |  | ||||||
|  |             if (!perms.containsKey(new DisguisePerm(disguise.getType()))) { | ||||||
|  |                 p.sendMessage(ChatColor.RED + "You do not have permission to modify this disguise"); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             try { | ||||||
|  |                 DisguiseParser.callMethods(p, disguise, perms.get(new DisguisePerm(disguise.getType())), new ArrayList<String>(), | ||||||
|  |                         options); | ||||||
|  |                 p.sendMessage(ChatColor.RED + "Modified the disguise!"); | ||||||
|  |             } | ||||||
|  |             catch (DisguiseParseException ex) { | ||||||
|  |                 if (ex.getMessage() != null) { | ||||||
|  |                     p.sendMessage(ex.getMessage()); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception ex) { | ||||||
|  |                 ex.printStackTrace(); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -538,4 +577,25 @@ public class DisguiseListener implements Listener { | |||||||
|         disguiseEntity.put(player, disguise); |         disguiseEntity.put(player, disguise); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public void setDisguiseModify(final String player, String[] args) { | ||||||
|  |         if (disguiseRunnable.containsKey(player)) { | ||||||
|  |             BukkitRunnable run = disguiseRunnable.remove(player); | ||||||
|  |             run.cancel(); | ||||||
|  |             run.run(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         BukkitRunnable runnable = new BukkitRunnable() { | ||||||
|  |             @Override | ||||||
|  |             public void run() { | ||||||
|  |                 disguiseModify.remove(player); | ||||||
|  |                 disguiseRunnable.remove(player); | ||||||
|  |             } | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  |         runnable.runTaskLater(plugin, 20 * DisguiseConfig.getDisguiseEntityExpire()); | ||||||
|  |  | ||||||
|  |         disguiseRunnable.put(player, runnable); | ||||||
|  |         disguiseModify.put(player, args); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -26,6 +26,10 @@ import me.libraryaddict.disguise.commands.DisguiseCloneCommand; | |||||||
| import me.libraryaddict.disguise.commands.DisguiseCommand; | import me.libraryaddict.disguise.commands.DisguiseCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseEntityCommand; | import me.libraryaddict.disguise.commands.DisguiseEntityCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseHelpCommand; | import me.libraryaddict.disguise.commands.DisguiseHelpCommand; | ||||||
|  | import me.libraryaddict.disguise.commands.DisguiseModifyCommand; | ||||||
|  | import me.libraryaddict.disguise.commands.DisguiseModifyEntityCommand; | ||||||
|  | import me.libraryaddict.disguise.commands.DisguiseModifyPlayerCommand; | ||||||
|  | import me.libraryaddict.disguise.commands.DisguiseModifyRadiusCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguisePlayerCommand; | import me.libraryaddict.disguise.commands.DisguisePlayerCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseRadiusCommand; | import me.libraryaddict.disguise.commands.DisguiseRadiusCommand; | ||||||
| import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand; | import me.libraryaddict.disguise.commands.DisguiseViewSelfCommand; | ||||||
| @@ -35,8 +39,8 @@ import me.libraryaddict.disguise.commands.UndisguiseEntityCommand; | |||||||
| import me.libraryaddict.disguise.commands.UndisguisePlayerCommand; | import me.libraryaddict.disguise.commands.UndisguisePlayerCommand; | ||||||
| import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand; | import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand; | ||||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||||
| import me.libraryaddict.disguise.disguisetypes.MetaIndex; |  | ||||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||||
|  | import me.libraryaddict.disguise.disguisetypes.MetaIndex; | ||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; | ||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher; | ||||||
| import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher; | import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher; | ||||||
| @@ -116,6 +120,10 @@ public class LibsDisguises extends JavaPlugin { | |||||||
|         registerCommand("disguiseclone", new DisguiseCloneCommand()); |         registerCommand("disguiseclone", new DisguiseCloneCommand()); | ||||||
|         registerCommand("libsdisguises", new LibsDisguisesCommand()); |         registerCommand("libsdisguises", new LibsDisguisesCommand()); | ||||||
|         registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); |         registerCommand("disguiseviewself", new DisguiseViewSelfCommand()); | ||||||
|  |         registerCommand("disguisemodify", new DisguiseModifyCommand()); | ||||||
|  |         registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand()); | ||||||
|  |         registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand()); | ||||||
|  |         registerCommand("disguisemodifyradius", new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax"))); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             Metrics metrics = new Metrics(this); |             Metrics metrics = new Metrics(this); | ||||||
|   | |||||||
| @@ -66,7 +66,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor { | |||||||
|         return newArgs.toArray(new String[0]); |         return newArgs.toArray(new String[0]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String getPermNode() { |     public final String getPermNode() { | ||||||
|         if (this instanceof DisguiseCommand) { |         if (this instanceof DisguiseCommand) { | ||||||
|             return "disguise"; |             return "disguise"; | ||||||
|         } |         } | ||||||
| @@ -79,8 +79,21 @@ public abstract class DisguiseBaseCommand implements CommandExecutor { | |||||||
|         else if (this instanceof DisguiseRadiusCommand) { |         else if (this instanceof DisguiseRadiusCommand) { | ||||||
|             return "disguiseradius"; |             return "disguiseradius"; | ||||||
|         } |         } | ||||||
|         else |         else if (this instanceof DisguiseModifyCommand) { | ||||||
|  |             return "disguisemodify"; | ||||||
|  |         } | ||||||
|  |         else if (this instanceof DisguiseModifyEntityCommand) { | ||||||
|  |             return "disguisemodifyentity"; | ||||||
|  |         } | ||||||
|  |         else if (this instanceof DisguiseModifyPlayerCommand) { | ||||||
|  |             return "disguisemodifyplayer"; | ||||||
|  |         } | ||||||
|  |         else if (this instanceof DisguiseModifyRadiusCommand) { | ||||||
|  |             return "disguisemodifyradius"; | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|             throw new UnsupportedOperationException("Unknown disguise command, perm node not found"); |             throw new UnsupportedOperationException("Unknown disguise command, perm node not found"); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) { |     protected HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender) { | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import org.bukkit.ChatColor; | |||||||
| import org.bukkit.command.Command; | import org.bukkit.command.Command; | ||||||
| import org.bukkit.command.CommandSender; | import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.command.TabCompleter; | import org.bukkit.command.TabCompleter; | ||||||
|  | import org.bukkit.entity.Entity; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.DisguiseAPI; | import me.libraryaddict.disguise.DisguiseAPI; | ||||||
| @@ -27,7 +28,7 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | |||||||
| public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { | public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (!(sender instanceof Entity)) { | ||||||
|             sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); |             sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -27,11 +27,16 @@ import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo; | |||||||
| public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter { | public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter { | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { |     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||||||
|         if (sender.getName().equals("CONSOLE")) { |         if (!(sender instanceof Player)) { | ||||||
|             sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); |             sender.sendMessage(ChatColor.RED + "You may not use this command from the console!"); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (getPermissions(sender).isEmpty()) { | ||||||
|  |             sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (args.length == 0) { |         if (args.length == 0) { | ||||||
|             sendCommandUsage(sender, getPermissions(sender)); |             sendCommandUsage(sender, getPermissions(sender)); | ||||||
|             return true; |             return true; | ||||||
| @@ -56,7 +61,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|  |  | ||||||
|         LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise); |         LibsDisguises.getInstance().getListener().setDisguiseEntity(sender.getName(), disguise); | ||||||
|  |  | ||||||
|         sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseEntityExpire() |         sender.sendMessage(ChatColor.RED + "Right click an entity in the next " + DisguiseConfig.getDisguiseEntityExpire() | ||||||
|                 + " seconds to disguise it as a " + disguise.getType().toReadable() + "!"); |                 + " seconds to disguise it as a " + disguise.getType().toReadable() + "!"); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| @@ -64,6 +69,11 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom | |||||||
|     @Override |     @Override | ||||||
|     public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) { |     public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) { | ||||||
|         ArrayList<String> tabs = new ArrayList<String>(); |         ArrayList<String> tabs = new ArrayList<String>(); | ||||||
|  |  | ||||||
|  |         if (!(sender instanceof Player)) { | ||||||
|  |             return tabs; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         String[] args = getArgs(origArgs); |         String[] args = getArgs(origArgs); | ||||||
|  |  | ||||||
|         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender); |         HashMap<DisguisePerm, HashMap<ArrayList<String>, Boolean>> perms = getPermissions(sender); | ||||||
|   | |||||||
| @@ -690,8 +690,16 @@ public class DisguiseParser { | |||||||
|         // Copy strings to their new range |         // Copy strings to their new range | ||||||
|         String[] newArgs = new String[args.length - toSkip]; |         String[] newArgs = new String[args.length - toSkip]; | ||||||
|         System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip); |         System.arraycopy(args, toSkip, newArgs, 0, args.length - toSkip); | ||||||
|         args = newArgs; |  | ||||||
|  |  | ||||||
|  |         callMethods(sender, disguise, optionPermissions, usedOptions, newArgs); | ||||||
|  |  | ||||||
|  |         // Alright. We've constructed our disguise. | ||||||
|  |         return disguise; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void callMethods(CommandSender sender, Disguise disguise, HashMap<ArrayList<String>, Boolean> optionPermissions, | ||||||
|  |             ArrayList<String> usedOptions, String[] args) | ||||||
|  |                     throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, DisguiseParseException { | ||||||
|         Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass()); |         Method[] methods = ReflectionFlagWatchers.getDisguiseWatcherMethods(disguise.getWatcher().getClass()); | ||||||
|  |  | ||||||
|         for (int i = 0; i < args.length; i += 2) { |         for (int i = 0; i < args.length; i += 2) { | ||||||
| @@ -970,8 +978,6 @@ public class DisguiseParser { | |||||||
|                 methodToUse.invoke(disguise, value); |                 methodToUse.invoke(disguise, value); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         // Alright. We've constructed our disguise. |  | ||||||
|         return disguise; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, String methodName) { |     private static DisguiseParseException parseToException(String expectedValue, String receivedInstead, String methodName) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user