Hi, I'm developing a mini game and want to reset the world after the game. Players can only build sandstone, so how can I remove (or replace with air) all the sandstone in the world?
PHP: $lv = $this->getServer()->getLevelByName("yourworld");for ($x = -999; $x <= 1000; $x++){ for ($y = 1; $y <= 100; $y++){ for ($z = -999; $z <= 100; $z++){ if ($lv->getBlockIdAt($x,$y,$z) == Item::SANDSTONE){ //no matter which sandstone you build $lv->setBlock(new Vector3($x,$y,$z), Block::get(0)); } } } } This will lag your server for 20 minutes, so it isn't good way Or, use WorldResetting method. Backup your worlds at specified folder and then copy the region files
/save-off after PHP: if($this->getServer()->isLevelLoaded(/*LevelName*/)){$this->getServer()->unloadLevel(/*levelname*/);}if(!$this->getServer()->isLevelLoaded(/*LevelName*/)){$this->getServer()->loadLevel(/*LevelName*/);} world become back again
Hmm.. You cant cancel levelsaveevent And only unloading them doesn't work either. Is there something like save-off for plugins? ->saveOff or so?