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

Code not doing anything

Comments in 'Plugin Development' started by BlubberBoy333, May 7, 2016.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    So I'm making yet another plugin and I'm having problems with it (as usual). The plugin is supposed to add a number to a config every time a player votes for the server, or someone uses the command to add a vote to the player. I set up a separate config file for all of the players that have voted for the server before. But when I run the command to add a vote to the player, it doesn't do anything. It says that the I added a vote to the player, but it doesn't actually add a vote to the player. Here's some of the code:
    PHP:
     public function addVote($player){
            if(
    $this->players->get($player) == null){
                
    $this->players->set($player1);
                
    $this->players->save();
            }else{
                
    $this->players->set(intval($this->players->get($player) + 1));
                
    $this->players->save();
                
    $rank $this->getConfig()->get($this->players->get($player));
                if(
    $rank !== null){
                    if(
    $this->getConfig()->get("AdminRank") == "false"){
                        
    $this->rankUp($player$this->players->get($player));
                    }else{
                        if(!(
    $this->getServer()->getPkayer($player)->isOp(true))){
                            
    $this->rankUp($player$this->players->get($player));
                        }
                    }
                }
            }
        }
       
        public function 
    rankUp($player$rank){
            
    $newRank $this->getPlugin()->get($rank);
            if(
    $this->getConfig()->get("Plugin") == "PureChat"){
                
    $command "setgroup $player $newRank";
                
    $this->getServer()->dispatchCommand(new ConsoleCommandSender$command);
            }elseif(
    $this->getConfig()->get("Plugin") == "CustomRanks"){
                
    $command "srank $player $newRank";
                
    $this->getServer()->dispatchCommand(new ConsoleCommandSender$command);
            }else{
                
    $this->getLogger()->info(TextFormat::RED.$this->getConfig()->get("Plugin")." doesn't work with this plugin!");
            }
            foreach(
    $this->getConfig()->get("Commands") as $i){
                
    $this->getServer()->dispatchCommand(new ConsoleCommandSenderstr_replace(array("{PLAYER}","{NAME}"), array($this->getServer()->getPlayer($player),$this->getServer()->getPlayer($player)->getName())));
            }
        }
    you can also find the plugin here.
  2. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
  3. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333

Share This Page

Advertisement