Stopping Chat For One Player

Discussion in 'Plugin Development' started by jbman223, Nov 6, 2012.

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

    jbman223

    How do you make it so when somebody types a command, the chat stops? I mean like a buy-craft style effect, where you can only see what the plugin has to say and nothing else. I also think that the server where you have to put in your password when you first join has this too. I can explain more if needed.

    I do not mean muting a player. That is simple.
     
  2. Offline

    JazzaG

    Something like this'll do the trick, albeit rather dirty ;)
    Code:
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e) {
        e.setCancelled(true);
     
        for(Player player : getServer().getOnlinePlayers()) {
            if(!isExcluded(player))
                player.sendMessage(e.getMessage());
        } 
    }
    
     
  3. Offline

    fireblast709

    JazzaG make sure that the event is not Async when you do this! Basically all player chat packets that come from a client are async
     
  4. Offline

    Sehales

    you don't have to cancel the event!!!
    Just use event.getRecipients() and remove the Player.
     
  5. Offline

    fireblast709

    Sehales read the javadocs, this is an unstable method :3
     
  6. Offline

    JazzaG

    With AsyncPlayerChatEvent, editing the recipient list is not guaranteed to work (source).

    Yes, one should do that check, but I was just suggesting a concept to OP.
     
  7. Offline

    Sehales

    it is working fine.....If someone do it wrong it is the problem of this person Wolvereness has told me that you can modify it so I believe he knows what he is doing. Whatever you shall never cancel the event, only for muting a player..
     
  8. Offline

    fireblast709

    Sehales it will work, yes, but it is not a suggested method
     
  9. Offline

    Sehales

    it was suggested to me... read my post... Whatever use what you want and do not discuss with me about that. I do it like it has been told to me and you are doing it like you has learned it okay?
     
  10. Offline

    fireblast709

    I am just saying that it will work most of the time, but Bukkit does not suggest it because it gives unstable results ;3

     
Thread Status:
Not open for further replies.

Share This Page