How do all items disappear on the ground? How do I fix this? PHP: class DropParticle extends PluginTask { public function __construct($plugin) { $this->plugin = $plugin; parent::__construct($plugin); } public function onRun($tick) { foreach($this->plugin->getServer()->getOnlinePlayers() as $player) { $name = $player->getName(); $inv = $player->getInventory(); $players = $player->getLevel()->getPlayers(); $level = $player->getLevel(); $cfg = new Config($this->plugin->getDataFolder() . "config.yml", Config::YAML); if(in_array($level->getFolderName(),$cfg->get("Lobbys"))) { foreach($level->getEntities() as $e) { if($e instanceof ItemEntity) { $player->getLevel()->removeEntity($e); } } } } }}
PHP: foreach($this->plugin->getServer()->getOnlinePlayers() as $player) {$player->getInventory()->clearAll(); //Inventory$player->getArmorInventory()->clearAll(); //Armor}
But, I would not do that on the PluginTask. Maybe something like that on your main file. PHP: //use pockermine/event/player/PlayerJoinEvent;public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $player->getInventory()->clearAll(); //Inventory $player->getArmorInventory()->clearAll(); //Armor}