public static boolean addClonedDisguise(String key, Disguise disguise) { if (DisguiseConfig.getMaxClonedDisguises() > 0) { if (clonedDisguises.containsKey(key)) { clonedDisguises.remove(key); } else if (DisguiseConfig.getMaxClonedDisguises() == clonedDisguises.size()) { clonedDisguises.remove(clonedDisguises.keySet().iterator().next()); } if (DisguiseConfig.getMaxClonedDisguises() > clonedDisguises.size()) { clonedDisguises.put(key, disguise); return true; } } return false; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = getPermissions(sender); if (map.isEmpty()) { sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); return true; } if (args.length == 0) { sendCommandUsage(sender, map); return true; } if (args.length == 1) { sender.sendMessage(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] + "'"); return true; } String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, newArgs.length); Disguise disguise; try { disguise = parseDisguise(sender, newArgs, map); } catch (DisguiseParseException ex) { if (ex.getMessage() != null) { sender.sendMessage(ex.getMessage()); } return true; } catch (Exception ex) { ex.printStackTrace(System.out); return true; } 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!"); return true; } if (DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { if (disguise.getWatcher() instanceof LivingWatcher) { ((LivingWatcher) disguise.getWatcher()).setCustomName(player.getDisplayName()); if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true); } } } 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() + "!"); } return true; }