Ejemplo n.º 1
0
 public static boolean acceptLastFriend(ProxiedPlayer p) { // p = der user
   PlayerData pd = PlayerData.get(p.getUniqueId());
   FriendRequest fr = pd.getFriendRequests().poll();
   if (fr == null) {
     Messages.FRIENDREQUEST_LAST_NOT_EXISTS.msg(p);
     return false;
   }
   Messages.FRIENDREQUEST_ACCEPTED.msg(p, "%player%", fr.getFriend().getFriendName());
   Messages.FRIENDREQUEST_ACCEPTED_FORSENDER.msg(fr.getSender(), "%player%", p.getName());
   PluginMessenger.sendMessage(p, "Friend", "Update");
   PluginMessenger.sendMessage(fr.getSender(), "Friend", "Update");
   fr.setAccepted(true);
   fr.setAnswered(true);
   return true;
 }
Ejemplo n.º 2
0
  @Override
  public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
    if (args.length <= 0) return null;
    Set<String> matches = new HashSet<>();
    switch (args[0].toLowerCase()) {
      case "add":
        {
          if (args.length != 2) break;
          if (args[1].length() >= 2) {
            String search = args[1].toLowerCase();
            for (ProxiedPlayer p : Util.PROXY.getPlayers()) {
              if (p.getName().toLowerCase().startsWith(search)) matches.add(p.getName());
            }
            return matches;
          }
          break;
        }

      case "remove":
        {
          if (args.length != 2) break;
          if (args[1].length() >= 2) {
            if (!(sender instanceof ProxiedPlayer)) return null;
            ProxiedPlayer player = (ProxiedPlayer) sender;
            String search = args[1].toLowerCase();
            PlayerData pd = PlayerData.get(player.getUniqueId());
            for (Friend friend : pd.getFriends().values()) {
              if (friend.getFriendName().toLowerCase().startsWith(search))
                matches.add(friend.getFriendName());
            }
          }
          break;
        }

      case "accept":
        {
          if (args.length != 3) break;
          if (args[2].length() >= 2) {
            if (!(sender instanceof ProxiedPlayer)) return null;
            ProxiedPlayer player = (ProxiedPlayer) sender;
            String search = args[2].toLowerCase();
            PlayerData pd = PlayerData.get(player.getUniqueId());
            for (FriendRequest fr : pd.getFriendRequests()) {
              if (fr.getSender().getName().toLowerCase().startsWith(search))
                matches.add(fr.getSender().getName());
            }
          }
          break;
        }

      default:
        {
          if (args.length == 1) {
            String search = args[0].toLowerCase();
            for (String subcmd : Util.FRIEND_SUBCOMMANDS) {
              if (subcmd.toLowerCase().startsWith(search)) matches.add(subcmd);
            }
          }
          break;
        }
    }
    return matches;
  }