Last active
August 10, 2020 14:02
-
-
Save jasonw4331/4cf2f5ac7f8e9db4e4877f981b5b27e0 to your computer and use it in GitHub Desktop.
Hunger restrictions for specific worlds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/** | |
* @name MultiWorldHunger | |
* @main jasonwynn10\MultiWorldHunger\Main | |
* @version 0.1.0 | |
* @api 3.0.0 | |
* @description A plugin script which applies hunger restrictions for specific worlds | |
* @author jasonwynn10 | |
*/ | |
namespace jasonwynn10\MultiWorldHunger { | |
use pocketmine\event\Listener; | |
use pocketmine\event\player\PlayerExhaustEvent; | |
use pocketmine\plugin\PluginBase; | |
class Main extends PluginBase implements Listener { | |
public function onEnable() { | |
$this->getServer()->getPluginManager()->registerEvents($this, $this); | |
} | |
public function onExhaust(PlayerExhaustEvent $event): void { | |
if(in_array($event->getPlayer()->getLevel()->getFolderName(), ["world", "world2"])) | |
$event->setCancelled(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment