diff --git a/changelogs/4.23.md b/changelogs/4.23.md index 031eaa1cc..750261e4b 100644 --- a/changelogs/4.23.md +++ b/changelogs/4.23.md @@ -49,3 +49,14 @@ Released 1st August 2023. ## Fixes - Fixed exponentially increasing lag when many hundreds of non-mergeable dropped items occupied the same space. This disproportionately affected SkyBlock servers due to large cactus farms using water to collect items together. + +# 4.23.5 +Released 9th August 2023. + +## General +- Updated translation data to [pmmp/Language 2.19.6](https://github.com/pmmp/Language/releases/tag/2.19.6). + +## Fixes +- Fixed `PluginBase->saveResource()` leaking file resources when the data file already exists in the plugin's data folder. This bug existed since 2014 and was only discovered recently. +- Fixed coral blocks becoming dead after calling `getDropsForCompatibleTool()` on them. +- Fixed `BlockDeathEvent->getOldState()` returning a block which is already dead. diff --git a/src/block/BaseCoral.php b/src/block/BaseCoral.php index 73b2c48d6..881f5e628 100644 --- a/src/block/BaseCoral.php +++ b/src/block/BaseCoral.php @@ -46,7 +46,7 @@ abstract class BaseCoral extends Transparent{ public function onScheduledUpdate() : void{ if(!$this->dead && !$this->isCoveredWithWater()){ - $ev = new BlockDeathEvent($this, $this->setDead(true)); + $ev = new BlockDeathEvent($this, (clone $this)->setDead(true)); $ev->call(); if(!$ev->isCancelled()){ $this->position->getWorld()->setBlock($this->position, $ev->getNewState()); diff --git a/src/block/CoralBlock.php b/src/block/CoralBlock.php index b90246561..c41c90182 100644 --- a/src/block/CoralBlock.php +++ b/src/block/CoralBlock.php @@ -55,7 +55,7 @@ final class CoralBlock extends Opaque{ } } if(!$hasWater){ - $ev = new BlockDeathEvent($this, $this->setDead(true)); + $ev = new BlockDeathEvent($this, (clone $this)->setDead(true)); $ev->call(); if(!$ev->isCancelled()){ $world->setBlock($this->position, $ev->getNewState()); @@ -65,7 +65,7 @@ final class CoralBlock extends Opaque{ } public function getDropsForCompatibleTool(Item $item) : array{ - return [$this->setDead(true)->asItem()]; + return [(clone $this)->setDead(true)->asItem()]; } public function isAffectedBySilkTouch() : bool{ diff --git a/src/plugin/PluginBase.php b/src/plugin/PluginBase.php index c8f3e1c39..23a98b943 100644 --- a/src/plugin/PluginBase.php +++ b/src/plugin/PluginBase.php @@ -226,19 +226,19 @@ abstract class PluginBase implements Plugin, CommandExecutor{ return false; } + $out = Path::join($this->dataFolder, $filename); + if(file_exists($out) && !$replace){ + return false; + } + if(($resource = $this->getResource($filename)) === null){ return false; } - $out = Path::join($this->dataFolder, $filename); if(!file_exists(dirname($out))){ mkdir(dirname($out), 0755, true); } - if(file_exists($out) && !$replace){ - return false; - } - $fp = fopen($out, "wb"); if($fp === false) throw new AssumptionFailedError("fopen() should not fail with wb flags");