use google traductor bad How to fix it PHP: ########################NO REAGIN#################### public function onRegainHealth(EntityRegainHealthEvent $event){ $player = $event->getEntity(); if($player instanceof Player){ $w = $player->getLevel()->getFolderName(); $regain = $this->getConfig()->get("disable-regen"); if(in_array($w, $regain)){ $event->setCancelled(); } } }
It's hard to tell without you sharing an example of your config, but my guess it that you're searching for $w inside of $regain, when neither of them appear to be an array.
Maybe try PHP: switch($regain){ case true: break; case 1: break; case "true": break; case "1": break; default: $event->setCancelled();} Could you share an example of what $regain might look like (in the config)?
Make sure the items in the array are strings. Code: ["world", "Lobby", "HUB", "WORLDS"] Not sure what else would cause the problem, other than maybe $regain isn't an array?? Try checking the type of the variable, if the above doesn't work.
The code you provided is perfectly OK. The problem may originate from somewhere else, such as not having registered the listener. I never knew that someone could read mind through the Internet cables to know whether those variables are arrays. This is already beyond the level of wild guessing. Do you even have the foggiest idea what you are saying? Why must $w be an array? It is very obvious that it is a level folder name from the OP.
Might I recommend adding a default output for $regain to be an empty array to prevent errors? $regain = $this->getConfig()->get("disable-regen", []);