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

My Cloud didnt update the Signs

Discussion in 'Development' started by EnteMomo, Jul 17, 2017.

  1. EnteMomo

    EnteMomo Silverfish

    Messages:
    22
    GitHub:
    Joshiiiii
    Hello guys, ive got a Problem with my Cloud.
    Ive made a Cloud wich transfer Players on another Server if they click on an esspecial Sign which named smthg like "Skywars-1". So everything is great but if I put a Sign with Skywars-1 for example. It Comes onetime the actually Data from my Database. But if I configure the Players for example to 2 then it doesnt update the Sign :/
    PHP:
    <?php

    namespace EnteMomo;

    use 
    pocketmine\block\Block;
    use 
    pocketmine\Command\Command;
    use 
    pocketmine\Command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\inventory\ChestInventory;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\tile\Chest;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\item\enchantment\Enchantment;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\level\Location;
    use 
    pocketmine\level\particle\HappyVillagerParticle;
    use 
    pocketmine\event\entity\ProjectileLaunchEvent;
    use 
    pocketmine\utils\Terminal;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\inventory\InventoryPickupItemEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\entity\Item as ItemEntity;
    use 
    pocketmine\math\Vector2;

    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\level\particle\RedstoneParticle;
    use 
    pocketmine\level\particle\LavaParticle;
    use 
    pocketmine\level\particle\WaterParticle;
    use 
    pocketmine\level\particle\PortalParticle;

    use 
    pocketmine\level\sound\PopSound;
    use 
    pocketmine\level\sound\GhastSound;

    class 
    Main extends PluginBase implements Listener {

        public 
    $prefix TextFormat::RED "Cloud" TextFormat::DARK_GRAY " |" TextFormat::WHITE " ";
        public 
    $screenzahl 0;
        public 
    $signregister false;
        public 
    $signregisterWHO "";
        public 
    $signregisterTitle "";
        public 
    $servername "Lobby";

        public function 
    onEnable(){

            @
    mkdir("/home/Datenbank/Main.yml");
            @
    mkdir("/home/Players");

            
    $config = new Config("/home/Datenbank/Main.yml"Config::YAML);

            if(empty(
    $config->get("Servers"))) {

                
    $config->set("Servers", array($this->servername
                
    ));
                
    $config->save();

            } else {

                if(!
    in_array($this->servername$config->get("Servers"))) {

                    
    $servers $config->set("Servers");
                    
    $servers[] = $this->servername;
                    
    $config->set("Servers"$servers);
                    
    $config->save();

                }

            }

            if(!
    $config->exists($this->servername)) {

                
    $config->setNested($this->servername ".ServerID"$this->servername);
                
    $config->setNested($this->servername ".ServerIP""IP");
                
    $config->setNested($this->servername ".ServerPort"19132);
                
    $config->setNested($this->servername ".ServerPlayers"0);
                
    $config->setNested($this->servername ".ServerMaxPlayers"$this->getServer()->getMaxPlayers());
                
    $config->setNested($this->servername ".ServerStatus""Lobby");
                
    $config->setNested($this->servername ".ServerMap""Voting");
                
    $config->save();

            }

            
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new RefreshSigns($this), 20);
            
    $this->getLogger()->info("Cloud aktiviert!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);

        }

        public function 
    onInteract(PlayerInteractEvent $event) {
            
    $cloud = new Config("/home/Datenbank/Main.yml"Config::YAML);
            
    $servermap $cloud->getNested($this->signregisterTitle.".ServerMap");
            
    $servermaxplayers $cloud->getNested($this->signregisterTitle.".ServerMaxPlayers");
            
    $serverplayers $cloud->getNested($this->signregisterTitle.".ServerPlayers");
            
    $block $event->getBlock();
            
    $player $event->getPlayer();
            
    $tile $player->getLevel()->getTile($block);

            if(
    $tile instanceof Sign) {

                
    $text $tile->getText();
                if (
    $text[0] == in_array($text[0], $cloud->getNested("Servers"))) {
                    
    $text $tile->getText();
                    if (
    $text[1] == TextFormat::GRAY "[".TextFormat::GREEN."Lobby".TextFormat::GRAY."]") {
                        
    $serverip $cloud->getNested($text[0].".ServerIP");
                        
    $serverport $cloud->getNested($text[0].".ServerPort");
                        
    $player->sendMessage($this->prefix."Du wirst auf den Server "TextFormat::RED.$text[0].TextFormat::GRAY." verschoben!");
                        
    $this->getServer()->dispatchCommand($event->getPlayer(), "transferserver ".$serverip." ".$serverport);
                    }

                }

            } else {
            
    $player->sendMessage("Lel");
            }
        }
    }

    class 
    RefreshSigns extends PluginTask {

        public 
    $prefix "";

        public function 
    __construct($plugin) {
            
    $this->plugin $plugin;
            
    $this->prefix $this->plugin->prefix;
            
    parent::__construct($plugin);
        }

        public function 
    onRun($tick) {

            
    $level $this->plugin->getServer()->getDefaultLevel();
            
    $tiles $level->getTiles();
            
    $cloud = new Config("/home/Datenbank/Main.yml"Config::YAML);
            foreach (
    $tiles as $t) {
                if (
    $t instanceof Sign) {
                    
    $text $t->getText();
                    if (
    $text[0] == in_array($text[0], $cloud->getNested("Servers"))){
                        
    $servermap $cloud->getNested($text[0].".ServerMap");
                        
    $servermaxplayers $cloud->getNested($text[0].".ServerMaxPlayers");
                        
    $serverplayers $cloud->getNested($text[0].".ServerPlayers");
                        
    $serverstatus $cloud->getNested($text[0].".ServerStatus");

                        if(
    $serverstatus != "Lobby" || $serverstatus != "Ende"){
                            
    $ingame TextFormat::RED."Im Spiel";
                        }
                        if(
    $serverstatus == "Lobby"){
                            
    $ingame TextFormat::GRAY."[".TextFormat::GREEN."Lobby".TextFormat::GRAY."]";
                        }
                        if(
    $serverstatus == "Ende"){
                            
    $ingame TextFormat::RESET."Server restartet...";
                        }
                        
    $t->setText(TextFormat::RESET.$text[0],TextFormat::GOLD.$servermap$ingameTextFormat::YELLOW.$serverplayers."/".$servermaxplayers);
                    }
                }
            }
        }
    }
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What do you mean by 'Cloud'?
     
    EdwardHamHam likes this.
  3. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    in_array returns a boolean value, so your 'if' statement is comparing a line of text on the sign to a boolean.
     
    InspectorGadget likes 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.