Development Assistance e.getRecipients().remove() doesn't work(help)

Discussion in 'Plugin Help/Development/Requests' started by UniqueNameDen, Feb 17, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    UniqueNameDen

    So I have a Player List:
    Code:
    public List<Player> Ignored = new ArrayList<Player>();
    I have EventHandler that removes Recipients in Ignored list:
    Code:
    @EventHandler(priority= EventPriority.HIGHEST)
    public void DenyChat(AsyncPlayerChatEvent e) {
        e.getRecipients().remove(plugin.Ignored);
    }
    
    I have a place where it adds players to Ignored player list
    plugin.Ignored.add(player);

    player is:
    Code:
    Player player = (Player) e.getPlayer();
    Basicly, I want players that are in a "tutorial" wouldn't receive chat

    I added a debug command /tutorialcfg geIgnoredPlayers
    Code:
    if (args[0].equalsIgnoreCase("getIgnoredPlayers")) {
        player.sendMessage("Ignored Players: " + plugin.Ignored);
    }
    
    it returns: [CraftPlayer{name=rik1301}, CraftPlayer{name=Tester}][/code]

    So why this doesn't work?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @UniqueNameDen The return values: because you don't use player.getName()
    And I am not sure if you can even remove a list from a list.
     
  3. Offline

    UniqueNameDen

    I wonder why it didn't give me an error, it asked for (Object o) or (ArrayList list)
    EDIT: gonna try with getName
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    UniqueNameDen

    @timtower nope, it does not work with names
    /tutorialcfg getIgnoredPlayers result:
    [randomtester]

    that's the same as
    e.getRecipients().remove("randomplayer"); right...?

    Can't I just make the player who is in ignored list ignore all Bukkit.getOnlinePlayers?
     
    Last edited: Feb 17, 2015
  6. Offline

    timtower Administrator Administrator Moderator

    @UniqueNameDen For remove you use e.getRecipients().remove(currentPlayerInList)
    For the printing you use getName()
    And that would make him ignore everybody, not everybody ignore him
     
  7. Offline

    UniqueNameDen

    after a lot of "Google"-ing

    All I needed to add is for(Player p : plugin.Ignored) {}
     
Thread Status:
Not open for further replies.

Share This Page