[Request] Disable your own chat.

Discussion in 'Archived: Plugin Requests' started by Cruxsky, Oct 30, 2011.

  1. Offline

    Cruxsky

    I'd like a plugin where when a person does a command, they'll stop receiving chat so no chat comes up. Then once the person does the command again, normal chat will resume for themselves.
    Need this to work with Permissions & EssentialsChat.

    this seems like it would be easy

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  2. Offline

    Technius

    It wouldn't be easy.
     
  3. Offline

    Cruxsky

    @Technius
    I don't think so. That plugin called buycraft disables you from receiving chat when you type /buy. and then to enable it again you type /ec
     
  4. Offline

    Technius

    That involves editing sent packets. And buycraft is how many people? 3? You would need someone more skilled than me to do something like this. And I'm pretty good.
     
  5. Offline

    Cruxsky

    Well... anyone else?
     
  6. Offline

    ThatBox

    You shouldn't make requests that are "too hard".
     
  7. Offline

    Cruxsky

    Well someone has to be able to do it.
     
  8. Offline

    DomovoiButler

    maybe this will work?just a guess

    first we need to make a
    List<Player> disabledChat;

    then on onCommand
    if(cmd.getname().equalsIgnoreCase("chat")){
    if(args[0].equalsIgnoreCase("off")){
    disableChat.add((Player)sender);
    }
    if(args[0].equalsIgnoreCase("on")){
    disableChat.remove((Player)sender)
    }
    }

    then on onPlayerChat
    for(Player recipients: event.getRecipients){
    for(Player disable: disabledChat){
    if(recipients.equals(disable)){
    event.setCancelled(true);
    }
    event.setCancelled(false);
    }
    }


    will this work?im just guessing okay?
     
  9. Offline

    Technius

    Here we go again.
    event.setCancelled(value) still continues the command chain. And what you're doing is cancelling the sender's chat.
     
  10. Offline

    Pinkishu

    Uhm can't you just remove them from recipient list of all the chat msgs?
     
  11. Offline

    DomovoiButler

    there is no setRecipients

    it was just a guess...just say no or yes

    found a solution...hmmm...or maybe someone already found it...i just confirming it if its right...so this will only work by editing sent packets right?wow...this would really need a high ranked java programmer...im going to research more of this as im still learning...but dont hope i will be doing this plugin cause as u can see, im not a plugin developer...im here to learn...xD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  12. Offline

    Cruxsky

  13. Offline

    Pinkishu

    ...

    playerChatEvent
    if( cancelled) return;
    ev.getRecipients().removeAll(lists of ppl that have turned it off);
     
  14. Offline

    Cruxsky

    Can't someone just look in the source of buycraft :p?
     
  15. Offline

    Pinkishu

    why? my way works :p
     
  16. Offline

    DomovoiButler

    that wouldn't work...i think...yeah...it will not work
     
  17. Offline

    Pinkishu

    It does work...
     
  18. Offline

    feildmaster

    Are you a moron? I don't even care if I get reported for that.

    event.getRecipients() is a a changeable value where you can apply ANY list function.

    I don't think I can ever take you seriously again. What?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  19. Offline

    Cruxsky

    Okay so what's happening?
     
  20. Offline

    DomovoiButler

    thats why i said 'ithink'...isnt getRecipients only gets the list of the recipients? not set it?
     
  21. Offline

    feildmaster

  22. Offline

    Pinkishu

    imo it gets a reference to the list, so if you modify it, it will be modified
     
  23. Offline

    Cruxsky

  24. Offline

    Pinkishu

  25. Offline

    Cruxsky

  26. Offline

    feildmaster

    You wanted permissions? I didn't make any.

    EDIT: To be honest. There's no point in limiting the command.

    Made a new version fixing a few bugs... But you aren't going to get much more out of me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  27. Buycraft dosent edit any packets, only uses the .GetRecipents() method.

    Code:
    // Do not allow the user to speak them selfs if they have disabled their chat
            if(this.buycraft.disabledChat.containsKey(event.getPlayer()))
            {
                event.setCancelled(true);
            }
            else
            {
                // Loop through each player who has their chat disabled and remove them from the receiving list
                for(Player player: this.buycraft.disabledChat.keySet())
                {
                    event.getRecipients().remove(player);
                }
            }
        }
    Sorry for bad formatting, its the forum not myself.
     
  28. Offline

    Cruxsky

    @feildmaster
    does it NOT block "/msg" messages?
    If it does block them could you make it so that is an exception?
     
  29. Offline

    feildmaster

    It doesn't block commands, no.There's no real way to block that.
     
  30. Offline

    Pinkishu

    I think he meant receiving /msg messages, not sure how those are handled
     

Share This Page