public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "Only players may check their mail"); return true; } Player player = (Player) sender; if (args.length == 0) { int number = TSNMySQL.getMailbox(player).size(); ChatColor color = number > 0 ? ChatColor.GREEN : ChatColor.GRAY; player.sendMessage(color + "You have " + number + " messages."); return true; } if (args.length == 1) { if (args[0].equalsIgnoreCase("empty")) { int number = TSNMySQL.getMailbox(player).size(); Iterator<String> it = TSNMySQL.getMailbox(player).iterator(); while (it.hasNext()) { it.remove(); } player.sendMessage( ChatColor.GREEN + Integer.toString(number) + " message(s) removed"); // No clue why toString is // needed } return true; } else if (args.length == 2) { if (args[0].equalsIgnoreCase("delete")) { int i; try { i = Integer.parseInt(args[1]); } catch (Exception e) { player.sendMessage(ChatColor.RED + args[1] + " is not a valid integer"); return true; } int number = TSNMySQL.getMailbox(player).size(); if (i > number) { player.sendMessage(ChatColor.RED + "You don't have " + i + " messages"); return true; } TSNMySQL.getMailbox(player).remove(i); } else if (args[0].equalsIgnoreCase("open")) { int i; try { i = Integer.parseInt(args[1]); } catch (Exception e) { player.sendMessage(ChatColor.RED + args[1] + " is not a valid integer"); return true; } int number = TSNMySQL.getMailbox(player).size(); if (i > number) { player.sendMessage(ChatColor.RED + "You don't have " + i + " messages"); return true; } player.sendMessage(TSNMySQL.getMailbox(player).get(i)); } } return false; }
public void onHeroChangeLevel(HeroChangeLevelEvent ev) { if (!(TSNMySQL.getFriends(ev.getHero().getPlayer()).isEmpty())) {} }