pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.26k stars 1.53k forks source link

VanillaEffects::fromString throws an exception when passing argument #4858

Closed jarne closed 2 years ago

jarne commented 2 years ago

Issue description

[11:35:48.645] [Server thread/CRITICAL]: ArgumentCountError: "Expected exactly 0 arguments, 1 passed" (EXCEPTION) in "pmsrc/src/utils/RegistryTrait" at line 91
--- Stack trace ---
  #0 plugins/HotBlock-master/src/surva/hotblock/tasks/PlayerBlockCheckTask(50): pocketmine\entity\effect\VanillaEffects::__callStatic(string[10] fromString, array[1])
  #1 pmsrc/src/scheduler/TaskHandler(117): surva\hotblock\tasks\PlayerBlockCheckTask->onRun()
  #2 pmsrc/src/scheduler/TaskScheduler(141): pocketmine\scheduler\TaskHandler->run()
  #3 pmsrc/src/plugin/PluginManager(466): pocketmine\scheduler\TaskScheduler->mainThreadHeartbeat(integer 116)
  #4 pmsrc/src/Server(1768): pocketmine\plugin\PluginManager->tickSchedulers(integer 116)
  #5 pmsrc/src/Server(1657): pocketmine\Server->tick()
  #6 pmsrc/src/Server(1046): pocketmine\Server->tickProcessor()
  #7 pmsrc/src/PocketMine(304): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#3, string[27] /Users/jarne/PocketMine-MP/, string[35] /Users/jarne/PocketMine-MP/plugins/)
  #8 pmsrc/src/PocketMine(327): pocketmine\server()
  #9 pmsrc(11): require(string[71] phar:///Users/jarne/PocketMine-MP/PocketMine-MP.phar/src/PocketMine.php)
--- End of exception information ---

Might be related to this line? https://github.com/pmmp/PocketMine-MP/blob/stable/src/utils/RegistryTrait.php#L90 ... which throws an exception when calling the method public static function fromString(string $name) : Effect{ of VanillaEffects.

Steps to reproduce the issue

  1. Use the VanillaEffects::fromString method in a plugin, e. g.: $effect = VanillaEffects::fromString("poison");

OS and versions

Plugins

$effect = VanillaEffects::fromString("poison");

Crashdump, backtrace or other files

https://crash.pmmp.io/view/6002153

alvin0319 commented 2 years ago

VanillaEffect doesn't have fromString method. You're supposed to use StringToEffectParser instead.

jarne commented 2 years ago

You're right, my PMMP sources weren't up to date, thank you 👍