Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't cancel PlayerChatEvent

Comments in 'Plugin Development' started by mamayadesu, Apr 3, 2015.

  1. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    Hello. I can't cancel event PlayerChatEvent.

    Code:
    PHP:
    public function onPlayerChat(PlayerChatEvent $event){
    $event->setCancelled();
    $event->getPlayer()->sendMessage("You can't use chat!!1");
    }
    I get message "You can't use chat!!1", but AND my message successful was sent to chat.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Using any other plugins? They may uncancel itm
    EvolSoft and Primus like this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function onPlayerChat(PlayerChatEvent $event){
    $event->setCancelled(true);
    $event-getName()->sendMessage("Message here...");
    }
    I think you must set the setCancelled(value)
  4. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Maybe you are running a plugin which makes conflicts with yours. Try to run your plugin without any other in your server and see what happens
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    true is the default value for Event::setCancelled().
  6. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    If another plugin is conflicting, maybe use
    PHP:
    $event->setMessage("");
    jojoe77777 likes this.

Share This Page

Advertisement