@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: String targetName = CommandUtils.getMatchedPlayerName(args[1]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; } Player target = mcMMOTarget.getPlayer(); Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); String playerName = player.getName(); if (player.equals(target)) { sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); return true; } if (PartyManager.inSameParty(player, target)) { sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); return true; } if (!PartyManager.canInvite(mcMMOPlayer)) { player.sendMessage(LocaleLoader.getString("Party.Locked")); return true; } Party playerParty = mcMMOPlayer.getParty(); mcMMOTarget.setPartyInvite(playerParty); sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); target.sendMessage( LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); return true; default: sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); return true; } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } switch (args.length) { case 0: McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); Player player = mcMMOPlayer.getPlayer(); if (Config.getInstance().getMcstatsScoreboardsEnabled()) { ScoreboardManager.setupPlayerScoreboard(player.getName()); ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer); } else { player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); CommandUtils.printGatheringSkills(player); CommandUtils.printCombatSkills(player); CommandUtils.printMiscSkills(player); int powerLevelCap = Config.getInstance().getPowerLevelCap(); if (powerLevelCap != Integer.MAX_VALUE) { player.sendMessage( LocaleLoader.getString( "Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); } else { player.sendMessage( LocaleLoader.getString( "Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); } } return true; default: return false; } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: if (CommandUtils.noConsoleUsage(sender)) { return true; } if (!hasSelfPermission(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } applyCommandAction(UserManager.getPlayer(sender.getName())); return true; case 1: if (!hasOtherPermission(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; } String playerName = CommandUtils.getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) { return true; } if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) { return true; } applyCommandAction(mcMMOPlayer); sendSuccessMessage(sender, playerName); return true; default: return false; } }
@Override public List<String> onTabComplete( CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches( args[0], playerNames, new ArrayList<String>(playerNames.size())); default: return ImmutableList.of(); } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 1: if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { ScoreboardManager.setupPlayerScoreboard(sender.getName()); } String playerName = Misc.getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in // the database. If it's not, abort the process. if (mcMMOPlayer == null) { PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) { return true; } if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile); return true; } sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); for (SkillType skill : SkillType.GATHERING_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); for (SkillType skill : SkillType.COMBAT_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); for (SkillType skill : SkillType.MISC_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } } else { Player target = mcMMOPlayer.getPlayer(); if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { if (!Permissions.inspectOffline(sender)) { sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); return true; } } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { return true; } if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer); return true; } sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); CommandUtils.printGatheringSkills(target, sender); CommandUtils.printCombatSkills(target, sender); CommandUtils.printMiscSkills(target, sender); sender.sendMessage( LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); } return true; default: return false; } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } switch (args.length) { case 0: Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); boolean isLucky = Permissions.lucky(player, skill); boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); float skillValue = mcMMOPlayer.getSkillLevel(skill); permissionsCheck(player); dataCalculations(player, skillValue, isLucky); if (Config.getInstance().getSkillUseBoard()) { ScoreboardManager.enablePlayerSkillScoreboard(player, skill); } if (!skill.isChildSkill()) { player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); player.sendMessage( LocaleLoader.getString( "Commands.XPGain", LocaleLoader.getString( "Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage( LocaleLoader.getString( "Effects.Level", (int) skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill))); } else { player.sendMessage( LocaleLoader.getString( "Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); player.sendMessage( LocaleLoader.getString( "Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child"))); player.sendMessage(LocaleLoader.getString("Effects.Child", (int) skillValue)); player.sendMessage( LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents"))); Set<SkillType> parents = FamilyTree.getParents(skill); for (SkillType parent : parents) { player.sendMessage( parent.getName() + " - " + LocaleLoader.getString( "Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent))); } } List<String> effectMessages = effectsDisplay(); if (!effectMessages.isEmpty()) { player.sendMessage( LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); if (isLucky) { String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); player.sendMessage( perkPrefix + LocaleLoader.getString( "Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName))); } for (String message : effectMessages) { player.sendMessage(message); } } List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky); if (!statsMessages.isEmpty()) { player.sendMessage( LocaleLoader.getString( "Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); for (String message : statsMessages) { player.sendMessage(message); } } player.sendMessage( LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase())); return true; default: return skillGuideCommand.onCommand(sender, command, label, args); } }
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Party party = UserManager.getPlayer((Player) sender).getParty(); if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4")); return true; } switch (args.length) { case 2: ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase()); if (mode == null) { sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>")); return true; } handleChangingShareMode(party, mode); return true; case 3: boolean toggle; if (CommandUtils.shouldEnableToggle(args[2])) { toggle = true; } else if (CommandUtils.shouldDisableToggle(args[2])) { toggle = false; } else { sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); return true; } try { handleToggleItemShareCategory( party, ItemShareType.valueOf(args[1].toUpperCase()), toggle); } catch (IllegalArgumentException ex) { sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); } return true; default: sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>")); sender.sendMessage( LocaleLoader.getString( "Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); return true; } }