From 59c88fe7f714abb88f2d472bf41d15478d43d4e7 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 9 Aug 2023 12:21:09 +0100 Subject: [PATCH] Added WorldDifficultyChangeEvent --- .../world/WorldDifficultyChangeEvent.php | 44 +++++++++++++++++++ src/world/World.php | 2 + 2 files changed, 46 insertions(+) create mode 100644 src/event/world/WorldDifficultyChangeEvent.php diff --git a/src/event/world/WorldDifficultyChangeEvent.php b/src/event/world/WorldDifficultyChangeEvent.php new file mode 100644 index 000000000..90cee376a --- /dev/null +++ b/src/event/world/WorldDifficultyChangeEvent.php @@ -0,0 +1,44 @@ +oldDifficulty; } + + public function getNewDifficulty() : int{ return $this->newDifficulty; } +} diff --git a/src/world/World.php b/src/world/World.php index 7d9311c70..934ff6690 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -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){