Added WorldDifficultyChangeEvent

This commit is contained in:
Dylan K. Taylor
2023-08-09 12:21:09 +01:00
parent 77dfbc4e23
commit 59c88fe7f7
2 changed files with 46 additions and 0 deletions

View File

@ -52,6 +52,7 @@ use pocketmine\event\world\ChunkLoadEvent;
use pocketmine\event\world\ChunkPopulateEvent;
use pocketmine\event\world\ChunkUnloadEvent;
use pocketmine\event\world\SpawnChangeEvent;
use pocketmine\event\world\WorldDifficultyChangeEvent;
use pocketmine\event\world\WorldDisplayNameChangeEvent;
use pocketmine\event\world\WorldParticleEvent;
use pocketmine\event\world\WorldSaveEvent;
@ -3127,6 +3128,7 @@ class World implements ChunkManager{
if($difficulty < 0 || $difficulty > 3){
throw new \InvalidArgumentException("Invalid difficulty level $difficulty");
}
(new WorldDifficultyChangeEvent($this, $this->getDifficulty(), $difficulty))->call();
$this->provider->getWorldData()->setDifficulty($difficulty);
foreach($this->players as $player){