1.12.2 Disable chat?

Discussion in 'Spigot Plugin Development' started by forgotth4ke, Feb 16, 2020.

  1. Hey,its me aggain.

    I just tried to disable the chat for some Players,but it wont work.. :/

    Code :

    public void onJoin(AsyncPlayerChatEvent event) {

    Player p = event.getPlayer();
    if(!p.hasPermission("registered.member")) {
    }else {

    May anyone help? :p
  2. SteelPhoenix


    What are you trying to achieve? If a player does not have a certain perm he cannot see his own chat messages..?
  3. Not only his Own,also all the others. :eek:
  4. SteelPhoenix


    Then why are you making it so that if player does not have a certain perm he cannot see his own chat messages? Just remove the players without perms from the recipients?
  5. Can u tell me how? Just getting more confused.. :eek:
  6. Loop through the recipents, if the recipent doesn't have the permission remove him from the recipents
  7. So as an Arraylist?
  8. Strahan


    No, the recipient list is a Set.

    Also, I'd not waste my time with looping. If the idea is to ban them from chat, just check if they have the permission node that marks them banned. If they do not, return. If they do, clear recips.
  9. SteelPhoenix


    Permissions may change and the event is async anywanys.
  10. But isnt this what im doing with .remove(p); ? o:
  11. try using event.setCancelled(true);
  12. At the end of my if thing?
  13. If i cancel the event,player X wont be able to *send* messages,but he still recieves.
    need to deny that aswell.

    I am not able to remove the forbidden Player from this Recipients.. how can that be so hard..
    #14 forgotth4ke, Feb 16, 2020
    Last edited: Feb 16, 2020
  14. Strahan


    Ah, I wasn't aware you wanted to block both in and out. In that case, just iterate over the recipients collection and remove if they are chat banned. It really isn't that difficult.
  15. Just solved this problem by my own,but thanks anyway.

    Got a new problem now..
    Do you know how I catch packets?
    (need to disable all Pluginmessages and Servermessages for those player aswell,and for any reason my IDE got issues with protocolib.. :/
  16. ProtocolLib is your best bet for listening to packets, what IDE are you using? And what 'issues' are you having..?
    • Agree Agree x 1
  17. Using Eclipse, latest Build.
    Issue..hm.. supress Warnings all the time..but there shouldnt be any SW..:/
  18. The thing is with these warnings is that they warn you from things that you shouldn't do or have not done correctly.
    You should at least read them.
    Furthermore, warnings don't prevent you from building the project.
    #19 robertlit, Feb 17, 2020
    Last edited: Feb 17, 2020
    • Agree Agree x 1