Skip to content

Instantly share code, notes, and snippets.

@jasonw4331
Last active August 10, 2020 14:02
Show Gist options
  • Save jasonw4331/4cf2f5ac7f8e9db4e4877f981b5b27e0 to your computer and use it in GitHub Desktop.
Save jasonw4331/4cf2f5ac7f8e9db4e4877f981b5b27e0 to your computer and use it in GitHub Desktop.
Hunger restrictions for specific worlds
<?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