Plugin Help

Discussion in 'Development' started by BattleAlan, Mar 10, 2019.

  1. BattleAlan

    BattleAlan Spider

    Messages:
    11
    How to fix.
    PHP:
    case "Godz":
                                if(
    $sender->hasPermission("tag.Godz") || $sender->isOp()){
                                    
    $pperms $this->getServer()->getPluginManager()->getPlugin("PurePerms");
                                    
    $prefix "§6God§r";
                                    
    $this->pureChat->setPrefix($prefix$sender);
                                    
    $sender->sendMessage("You change your Tag to §eGodz");
                                }else{
                                    if(!
    $sender->hasPermission("tag.Godz"));
                                        
    $sender->sendMessage("§8[§4!§8]§7You dont have this tag.")    ;                   
                                        }
                                break;
                                }
                            }
                        }
                    }
                }
            }
            return 
    true;
        }
    }
    Here the error
    PHP:
    [03:33:54] [Server thread/CRITICAL]: Error"Call to a member function setPrefix() on null" (EXCEPTIONin "plugins/phar_Tag_o9c7lGyfvQpIsR2.phar/src/Alan/Tag/Main" at line 70
     
  2. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    show me where $this->pureChat is defined
     
  3. BattleAlan

    BattleAlan Spider

    Messages:
    11
    LOL
     
  4. Jackthehack21

    Jackthehack21 Creeper

    Messages:
    3
    GitHub:
    jackthehack21
    Like @KielKing said, we cant see where its defined.
    If its defined by getting plugin via server ( ` $server->getPluginManager()->getPlugin('PluginName ` ) if the plugin does not exits it will return null, also your getting PurePerms for no use in that section...
    I would assume you meant to get PureChat and use that, if so i would check if its null before doing anything (as said above).
     
  5. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    what's so funny?
     
  6. BattleAlan

    BattleAlan Spider

    Messages:
    11
    PHP:
    <?php

    namespace Alan\Tag;

    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\entity\EntityDeathEvent;
    use 
    pocketmine\utils\Config;
    use 
    _64FF00\PureChat\PureChat;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\utils\TextFormat as TF;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;

    class 
    Main extends PluginBase implements Listener{

        private 
    $pureChat null;
        
    ###########################################################################
        ########################### IMPORTANT THINGS #################################
        ###########################################################################

        
    public function onEnable(){
            
    $this->getLogger()->info("Tag by Alan now enabled!");
        }

        public function 
    onCommand(CommandSender $senderCommand $commandstring $label, array $args) : bool {
            
            if(
    strtolower($command->getName()) === "tag") {
                
                if(
    count($args) < 1) {
                
                    
    $sender->sendMessage(TF::GRAY "§7Usage:§e/tag <list|use>");
                    return 
    true;
                }
                if(isset(
    $args[0])) {
                            
                    switch(
    $args[0]) {
                        case 
    "list":
                            
    $sender->sendMessage(TF::GRAY "•Available Tag•");
                            
    $sender->sendMessage(TF::GRAY "•Godz");
                            return 
    true;
                            break;
                        default:
                            
    $sender->sendMessage(TextFormat::RED "Usage: /tag <list|use>");
                            return 
    true;
                        break;
                        case 
    "use":
                            if (
    count($args) < 2) {
                                
    $sender->sendMessage(TextFormat::RED "Usage: /tag use <tag name>");
                                return 
    true;
                            }
                            if(
    $sender->hasPermission("tag.command") || $sender->isOp()){
                            if(isset(
    $args[1])) {
                            
                                switch(
    $args[1]) {
                                    
                                case 
    "Godz":
                                if(
    $sender->hasPermission("tag.Godz") || $sender->isOp()){
                                    
    $pperms $this->getServer()->getPluginManager()->getPlugin("PurePerms");
                                    
    $prefix "§6God§r";
                                    
    $this->pureChat->setPrefix($sender$prefix$this->pureChat->getConfig()->get("enable-multiworld-chat") ? $player->getLevel()->getName() : null);
                                    
    $sender->sendMessage("You change your Tag to §eGodz");
                                }else{
                                    if(!
    $sender->hasPermission("tag.Godz"));
                                        
    $sender->sendMessage("§8[§4!§8]§7You dont have this tag.")    ;                   
                                        }
                                break;
                                }
                            }
                        }
                    }
                }
            }
            return 
    true;
        }
    }
     
  7. Jackthehack21

    Jackthehack21 Creeper

    Messages:
    3
    GitHub:
    jackthehack21
    You don't assign $purechat to a plugin anywhere, so its definitely going to be null lol
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.