Inheritance: extends WeatherEvent, implements pocketmine\event\Cancellable
Example #1
0
 private function generateWeather()
 {
     if ($this->getServer()->getProperty("weather.enable", true)) {
         if ($this->getWeather() === Level::WEATHER_CLEARSKY) {
             $random = mt_rand(1, 1000000);
             if ($random <= $this->rainprob) {
                 Server::getInstance()->getPluginManager()->callEvent($ev = new WeatherChangeEvent($this, Level::WEATHER_CLEARSKY));
                 if (!$ev->isCancelled()) {
                     $this->setWeatherExecTick(mt_rand($this->raintime[0], $this->raintime[1]));
                     $this->setWeather(Level::WEATHER_RAIN);
                 }
             }
             return;
         }
         if ($this->getWeather() === Level::WEATHER_RAIN) {
             if ($this->weatherexectick <= 0) {
                 Server::getInstance()->getPluginManager()->callEvent($ev = new WeatherChangeEvent($this, Level::WEATHER_RAIN));
                 if (!$ev->isCancelled()) {
                     $this->weatherexectick = 0;
                     $this->setWeather(Level::WEATHER_CLEARSKY);
                     return;
                 }
             }
             $this->weatherexectick--;
             return;
         }
     }
     // Weather TODO : Thunder
 }