1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Indirect Modification of overloaded...

Discussion in 'Development' started by Junkdude, Jan 13, 2017.

  1. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    I'm getting this error and cant seem to figure it out
    Notice: Indirect modification of overloaded property pocketmine\utils\Config::$YaBoiJunk1 has no effect in C:\Users\Conner\Documents\PocketMine-MP\plugins\Factions-pp-master\src\HittmanA\factionspp\MainClass.php on line 111
    Code:
    PHP:
    <?php

    namespace HittmanA\factionspp;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\utils\Config;

    class 
    MainClass extends PluginBase implements Listener {

        
    /** @var Config */
        
    protected $fac;
        
    //Faction name tag coming soon >:D
        //$player->setDisplayName("My Rank" . $player->getName());
        
    public function onEnable() {
            @
    mkdir($this->getDataFolder());
            
    $this->facs = new Config($this->getDataFolder() . "factions.json"Config::JSON, []);
            
    $this->playerInfo = new Config($this->getDataFolder() . "players.json"Config::JSON, []);
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer()->getPluginManager()->registerEvents(new Events($this), $this);
            
    $this->getLogger()->info(TextFormat::YELLOW "Loaded!");
        }

        public function 
    onDisable() {
            
    $this->getLogger()->info(TextFormat::YELLOW "Unloading!");
        }

        public function 
    onJoin(PlayerJoinEvent $event) {
            
    $player $event->getPlayer();
            
    $dispName $player->getName();
            
    $fac $this->playerInfo->$dispName->faction;
            if(isset(
    $fac)) {
                
    $prefix "[$fac]";
                
    $player->setDisplayName($prefix " " $player->getName());
                
    $player->setNameTag($prefix " " $player->getName());
            }
        }
        
    ##$this->facs->$facWhosPowerYouWantToChange["power"] == 10;
    ##$this->facs->save(true);
        ##$power = $this->facs->$facName[“power”];
    ##$power += 10 //amount to add. Can also be a var
    ##$power -= 10

        
    public function onCommand(CommandSender $senderCommand $command$label, array $args) {
            
    $displayName $sender->getName();
            
    $subcmd strtolower(array_shift($args));
            switch (
    $command->getName()){
                case 
    "factionspp":
                case 
    "fpp":
                case 
    "f":
                    if(
    $sender instanceof Player) {
                            if(
    $subcmd === "create") {
                                if(isset(
    $args[0])) {
                                    
    $facName array_shift($args);
                                    if(isset(
    $this->playerInfo->$displayName["faction"])) {
                                        
    $sender->sendMessage(TextFormat::RED "You are already in a faction!");
                                    }else
                                    if(isset(
    $this->facs->$facName)){
                                        
    $sender->sendMessage(TextFormat::RED "A faction with this name already exists!");
                                    }elseif(!isset(
    $this->playerInfo->$displayName["faction"])) {
                                        if(!isset(
    $this->facs->$facName)){
                                        
    $this->facs->set($facName, [
                                            
    "name" => strtolower($facName),
                                            
    "display" => $facName,
                                            
    "leader" => $displayName,
                                            
    "officers" => [],
                                            
    "members" => [],
                                            
    "power" => 5
                                        
    ]);
                                        
    $this->playerInfo->set($displayName,[
                                            
    "name" => $displayName,
                                            
    "faction" => $facName,
                                            
    "role" => "Leader"
                                        
    ]);
                                        
    $this->facs->save(true);
                                        
    $this->playerInfo->save(true);
                                        
    $prefix "[".$facName."]";
                                        
    $sender->setDisplayName($prefix " " $displayName);
                                        
    $sender->setNameTag($prefix " " $displayName);
                                        
    $sender->sendMessage(TextFormat::GREEN "Faction created!");
                                    }
                                } else {
                                    
    $sender->sendMessage(TextFormat::GOLD "Usage: /factionspp create <name>");
                                }
                            }
                        }

                            elseif (
    $subcmd === "info") {
                                if(isset(
    $this->playerInfo->$displayName)) {
                                    
    $playerFPPProfile $this->playerInfo->$displayName;
                                    
    $playerFac $playerFPPProfile["faction"];
                                    
    $playerFacInfo $this->facs->$playerFac;
                                    
    $sender->sendMessage(TextFormat::GOLD "Faction: " $playerFac);
                                    
    $sender->sendMessage(TextFormat::GREEN "Your Role: " $playerFPPProfile["role"]);
                                }else{
                                    
    $sender->sendMessage(TextFormat::RED "You must be part of a faction to run this command!");
                                }
                            }elseif (
    $subcmd === "leave" || $subcmd === "quit") {
                                if(isset(
    $this->playerInfo->$displayName)) {
                                    
    $displayName $sender->getName();
                                    
    $playerFPPProfile $this->playerInfo->$displayName;
                                    
    $playerFac $playerFPPProfile["faction"];
                                    
    $playerFacInfo $this->facs->$playerFac;
                                    if(empty(
    $playerFacInfo["officers"]) || empty($playerFacInfo["members"])) {
                                        
    $this->playerInfo->$displayName["faction"] = " ";
                                        
    $this->playerInfo->$displayName["role"] = " ";
                                        
    $this->facs->remove($playerFac);
                                        
    $sender->sendMessage(TextFormat::GREEN "You have left the faction!");
                                    }else{
                                        if(
    $playerFPPProfile["role"]) {
                                            
    $this->facs->$playerFac[$playerFPPProfile["rank"] . "s"]->remove($displayName);
                                            
    $this->facs->$playerFac["faction"] = " ";
                                            
    $this->facs->$playerFac["role"] = " ";
                                            
    $sender->sendMessage(TextFormat::GREEN "You have left the faction!");
                                        }else{
                                            
    $sender->sendMessage(TextFormat::RED "You must make another player leader first!");
                                        }
                                    }
                                }else{
                                    
    $sender->sendMessage(TextFormat::RED "You must be part of a faction to run this command!");
                                }
                            }
                    } else {
                        
    $sender->sendMessage(TextFormat::RED "Please run this command in-game");
                    }
                }
        
    $this->facs->save(true);
        
    $this->playerInfo->save(true);
    }
    }
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The third & fourth line of onJoin must be...
    PHP:
    $fac $this->playerInfo;
    If (isset(
    $fac->dispName) && isset($fac->dispName->fac)) {
     
    applqpak likes this.
  3. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    this fixed nothing
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    what is line 111?
     
  5. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    $this->playerInfo->$displayName["role"] = " ";
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    PHP:
    $this->playerInfo->$displayName["faction"] = " ";
    $this->playerInfo->$displayName["role"] = " ";
    wtf is that? why on earth do you try to access static variables with -> while there are no static variables? And why do you even think the config object should have any var named $displayName
     
    Muqsit and applqpak like this.
  7. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    displayname is the senders name, i defined that on the 2nd line of the command function. I know its in there because when u do /f create (whatever) it adds it. Yes i am doing that first
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That is not possible.
    You cannot access static properties like that. Learn to code, don't code to learn.
     
    jasonwynn10 likes this.
  9. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    You can't really learn coding without coding anything
     
    jasonwynn10 and HittmanA like this.
  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.