tedo0627 / RedstoneCircuit

This is the PocketMine plugin that implements the Redstone circuit.
GNU General Public License v3.0
84 stars 47 forks source link

fix crash #106

Closed xxFLORII closed 1 year ago

xxFLORII commented 1 year ago

This should fix this error:

`2022-12-26 [10:03:53.547] [Server thread/CRITICAL]: TypeError: "tedo0627\redstonecircuit\block\mechanism\BlockCommand::dispatch(): Return value must be of type bool, null returned" (EXCEPTION) in "plugins/RedstoneCircuit.phar/src/tedo0627/redstonecircuit/block/mechanism/BlockCommand" at line 313 --- Stack trace ---

0 plugins/RedstoneCircuit.phar/src/tedo0627/redstonecircuit/block/mechanism/BlockCommand(228): tedo0627\redstonecircuit\block\mechanism\BlockCommand->dispatch()

1 plugins/RedstoneCircuit.phar/src/tedo0627/redstonecircuit/block/mechanism/BlockCommand(184): tedo0627\redstonecircuit\block\mechanism\BlockCommand->execute()

2 pmsrc/src/world/World(922): tedo0627\redstonecircuit\block\mechanism\BlockCommand->onScheduledUpdate()

3 pmsrc/src/world/World(879): pocketmine\world\World->actuallyDoTick(int 14190)

4 pmsrc/src/world/WorldManager(348): pocketmine\world\World->doTick(int 14190)

5 pmsrc/src/Server(1818): pocketmine\world\WorldManager->tick(int 14190)

6 pmsrc/src/Server(1700): pocketmine\Server->tick()

7 pmsrc/src/Server(1061): pocketmine\Server->tickProcessor()

8 pmsrc/src/PocketMine(339): pocketmine\Server->__construct(object BaseClassLoader#3, object pocketmine\utils\MainLogger#4, string[34] /home/clientservers/server-836907/, string[42] /home/clientservers/server-836907/plugins/)

9 pmsrc/src/PocketMine(362): pocketmine\server()

10 pmsrc(11): require(string[73] phar:///home/serversoftwares/PocketMine_1.19.50_2.phar/src/PocketMine.php)

--- End of exception information ---`

tedo0627 commented 1 year ago

I did not feel the need to change the return value of the dispatch function. I would change it like this. In function dispatch of class BlockCommand

$successful = $target->execute($this, $sentCommandLabel, $args);

$result = $target->execute($this, $sentCommandLabel, $args);
if (is_bool($result)) $successful = $result;

And, I don't think RegisterMappingsAsync class is necessary either.

xxFLORII commented 1 year ago

i‘ve added RegisterMappingsAsync to pass all poggit checks.

I will also implement the other suggestion immediately.

tedo0627 commented 1 year ago

The poggit check is due to a phpstan error and can be ignored.

Severity: Error

PHPStan Error
An error occurred while running PHPStan

PHPStan failed with ID 'phpstan-b785-38ad42bd', contact support with the ID for help if this persists.

This error hasn't gone away for a long time, but I'm too lazy to report it, so I'm leaving it alone.

xxFLORII commented 1 year ago

should be done now.

xxFLORII commented 1 year ago

pushed

tedo0627 commented 1 year ago

Thank you