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

Does Nothing

Comments in 'Plugin Development' started by Skullex, Apr 30, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    onChat this does nothing

    PHP:
    <?php

    namespace CC;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\event\player\PlayerChatEvent;

    class 
    Main extends PluginBase implements Listener{
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
        public function 
    onChat(PlayerChatEvent $event){
            if(
    $player->hasPermission("chat.off")){
                
    $event->setCancelled(true);
                if(
    $event->isCancelled(true)){
                    
    $player $event->getPlayer();
                    
    $player->sendMessage(TF::WHITE."[".TF::RED." ! ".TF::WHITE."]".TF::YELLOW." You must vote to chat, type ".TF::RED."/".TF::GREEN."vote".TF::YELLOW." for more ".TF::AQUA."information".TF::YELLOW."!");
                    if(
    $player->hasPermission("chat.on")){
                        
    $event->setCancelled(false);
                    }
                }
            }
        }
    }
    plugin.yml:

    Code:
    name: CancelChat(VOTE)
    version: 1.0.0
    author: Skullex
    api:
    - 1.0.0
    - 2.0.0
    - 1.13.0
    - 1.14.0
    main: CC\Main
    description: Rumo idea
    
    permissions:
      chat.on:
        description: "Gives you the ability to chat"
        default: false
            children:
              chat.off: 
                default: true
                description: "Takes away your ability to chat"
    
    Any help on what mistakes I made?
  2. cake23
    Offline

    cake23 Active Member

    Joined:
    Aug 10, 2015
    Posts:
    124
    Minecraft User:
    TheEnd
    Maybe you didnt define $player? :D
    PHP:
    public function onChat(PlayerChatEvent $event){
            if(
    $player->hasPermission("chat.off")){ // $event->getPlayer()->has....
                
    $event->setCancelled(true);
                if(
    $event->isCancelled(true)){
                    
    $player $event->getPlayer();
                    
    $player->sendMessage(TF::WHITE."[".TF::RED." ! ".TF::WHITE."]".TF::YELLOW." You must vote to chat, type ".TF::RED."/".TF::GREEN."vote".TF::YELLOW." for more ".TF::AQUA."information".TF::YELLOW."!");
                    if(
    $player->hasPermission("chat.on")){
                        
    $event->setCancelled(false);
                    }
                }
            }
        }
    Skullex likes this.
  3. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I'll see what I can do :p
    cake23 likes this.
  4. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    TY
    CookieSteve and cake23 like this.
  5. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    lel
    Skullex likes this.

Share This Page

Advertisement