What is the wrong in this code?? PHP: <?php/*this is a special way to show your server info to the players !by 7awariGamer !!*/namespace info;use pocketmine\event\inventory\InventoryOpenEvent;use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\event\player\PlayerExhaustEvent;use pocketmine\level\Location;use pocketmine\level\particle\BubbleParticle;use pocketmine\level\particle\ExplodeParticle;use pocketmine\level\particle\HeartParticle;use pocketmine\level\particle\HugeExplodeParticle;use pocketmine\level\Position;use pocketmine\event\entity\ProjectileLaunchEvent;use pocketmine\utils\Terminal;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\player\PlayerDropItemEvent;use pocketmine\event\inventory\InventoryPickupItemEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\scheduler\Task;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\Entity;use pocketmine\utils\Config;use pocketmine\block\Block;use pocketmine\level\Level;use pocketmine\utils\TextFormat;use pocketmine\item\Item;use pocketmine\entity\Item as ItemEntity;use pocketmine\math\Vector3;use pocketmine\math\Vector2;use pocketmine\level\particle\DustParticle;use pocketmine\level\particle\FlameParticle;use pocketmine\level\particle\RedstoneParticle;use pocketmine\level\particle\LavaParticle;use pocketmine\level\particle\PortalParticle;use pocketmine\level\sound\PopSound;use pocketmine\level\sound\GhastSound;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\player\PlayerCommandPreprocessEvent;use PowerNick\NickAPI\NickAPI;use PowerNick\PowerNick;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->rgisterEvents($this, $this); $this->getLogger()->Info("the ppppp enabled LOL"); $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10); $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20); $this->getServer()->getNetwork()->setName(TextFormat::BOLD . TextFormat::GREEN . "MineLegends"); $this->getServer()->getDefaultLevel()->setTime(1000); $this->getServer()->getDefaultLevel()->stopTime(); } public function onDesable(){ $this->getLogger()->Info("the ppppp has fucking error LOL"); } public function onJoin(PlayerJoinEvent $ev) { $player->getInventory()->setItem(1, Item::get(330)->setCustomName("§l§1Info")); } public function onCommand(CommandSender $sender, Command $cmd, string $label , array $args){ if($sender instanceof Player){ switch($cmd->getName()){ case "hub"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); case "lobby"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); return true; } } } public function onInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $in = $event->getPlayer()->getInventory()->getItemInHand()->getCustomName(); $inv = $player->getInventory(); $blockid = $event->getBlock()->getID(); $block = $event->getBlock(); $config = new Config($this->getDataFolder() . "config.yml", Config::YAML); if ($in == "§l§1Info") { $this->getServer()->dispatchCommand($event->getPlayer(), ""); }}} ?>
PHP: <?php/*this is a special way to show your server info to the players !by 7awariGamer !!*/namespace info;use pocketmine\event\inventory\InventoryOpenEvent;use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\event\player\PlayerExhaustEvent;use pocketmine\level\Location;use pocketmine\level\particle\BubbleParticle;use pocketmine\level\particle\ExplodeParticle;use pocketmine\level\particle\HeartParticle;use pocketmine\level\particle\HugeExplodeParticle;use pocketmine\level\Position;use pocketmine\event\entity\ProjectileLaunchEvent;use pocketmine\utils\Terminal;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\player\PlayerDropItemEvent;use pocketmine\event\inventory\InventoryPickupItemEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\scheduler\Task;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\Entity;use pocketmine\utils\Config;use pocketmine\block\Block;use pocketmine\level\Level;use pocketmine\utils\TextFormat;use pocketmine\item\Item;use pocketmine\entity\Item as ItemEntity;use pocketmine\math\Vector3;use pocketmine\math\Vector2;use pocketmine\level\particle\DustParticle;use pocketmine\level\particle\FlameParticle;use pocketmine\level\particle\RedstoneParticle;use pocketmine\level\particle\LavaParticle;use pocketmine\level\particle\PortalParticle;use pocketmine\level\sound\PopSound;use pocketmine\level\sound\GhastSound;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\player\PlayerCommandPreprocessEvent;use PowerNick\NickAPI\NickAPI;use PowerNick\PowerNick;class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->rgisterEvents($this, $this); $this->getLogger()->Info("the ppppp enabled LOL"); //$this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10); //$this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20); $this->getServer()->getNetwork()->setName(TextFormat::BOLD . TextFormat::GREEN . "MineLegends"); $this->getServer()->getDefaultLevel()->setTime(1000); $this->getServer()->getDefaultLevel()->stopTime(); } public function onDisable() { $this->getLogger()->Info("the ppppp has fucking error LOL"); } public function onJoin(PlayerJoinEvent $ev) { $player->getInventory()->setItem(1, Item::get(330)->setCustomName("§l§1Info")); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) { if ($sender instanceof Player) { switch ($cmd->getName()) { case "hub"; $item = Item::get(330, 0, 1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); break; case "lobby"; $item = Item::get(330, 0, 1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); break; } } return true; } public function onInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $in = $event->getPlayer()->getInventory()->getItemInHand()->getCustomName(); $inv = $player->getInventory(); $blockid = $event->getBlock()->getID(); $block = $event->getBlock(); $config = new Config($this->getDataFolder() . "config.yml", Config::YAML); if ($in == "§l§1Info") { $this->getServer()->dispatchCommand($event->getPlayer(), ""); } }} A lot of useless imported classes by the way, but this should work.
That's my code PHP: <?php/*this is a special way to show your server info to the players !by 7awariGamer !!*/namespace info;use pocketmine\event\inventory\InventoryOpenEvent;use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\event\player\PlayerExhaustEvent;use pocketmine\level\Location;use pocketmine\level\particle\BubbleParticle;use pocketmine\level\particle\ExplodeParticle;use pocketmine\level\particle\HeartParticle;use pocketmine\level\particle\HugeExplodeParticle;use pocketmine\level\Position;use pocketmine\event\entity\ProjectileLaunchEvent;use pocketmine\utils\Terminal;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\player\PlayerDropItemEvent;use pocketmine\event\inventory\InventoryPickupItemEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\scheduler\Task;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\Entity;use pocketmine\utils\Config;use pocketmine\block\Block;use pocketmine\level\Level;use pocketmine\utils\TextFormat;use pocketmine\item\Item;use pocketmine\entity\Item as ItemEntity;use pocketmine\math\Vector3;use pocketmine\math\Vector2;use pocketmine\level\particle\DustParticle;use pocketmine\level\particle\FlameParticle;use pocketmine\level\particle\RedstoneParticle;use pocketmine\level\particle\LavaParticle;use pocketmine\level\particle\PortalParticle;use pocketmine\level\sound\PopSound;use pocketmine\level\sound\GhastSound;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\player\PlayerCommandPreprocessEvent;use PowerNick\NickAPI\NickAPI;use PowerNick\PowerNick;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->rgisterEvents($this, $this); $this->getLogger()->Info("the ppppp enabled LOL"); $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10); $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20); $this->getServer()->getNetwork()->setName(TextFormat::BOLD . TextFormat::GREEN . "MineLegends"); $this->getServer()->getDefaultLevel()->setTime(1000); $this->getServer()->getDefaultLevel()->stopTime(); } public function onDesable(){ $this->getLogger()->Info("the ppppp has fucking error LOL"); } public function onJoin(PlayerJoinEvent $ev) { $player->getInventory()->setItem(1, Item::get(330)->setCustomName("§l§1Info")); } public function onCommand(CommandSender $sender, Command $cmd, string $label , array $args){ if($sender instanceof Player){ switch($cmd->getName()){ case "hub"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); case "lobby"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); return true; } } } public function onInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $in = $event->getPlayer()->getInventory()->getItemInHand()->getCustomName(); $inv = $player->getInventory(); $blockid = $event->getBlock()->getID(); $block = $event->getBlock(); $config = new Config($this->getDataFolder() . "config.yml", Config::YAML); if ($in == "§l§1Info") { $this->getServer()->dispatchCommand($event->getPlayer(), ""); }}} ?>
Please work with the people who are trying to help you, show us the error and point out line 56. PHP: public function onJoin(PlayerJoinEvent $ev) { $player->getInventory()->setItem(1, Item::get(330)->setCustomName("§l§1Info")); } You forgot to define $player here PHP: public function onCommand(CommandSender $sender, Command $cmd, string $label , array $args){ You also forgot to add :bool to your onCommand function
I was so kind, and have removed the spelling mistakes, the unnecessary statements and spaces, as well as fixed your bugs. Have fun with it. PHP: <?php/*this is a special way to show your server info to the players !by 7awariGamer !!*/namespace info;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\Listener;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\plugin\PluginBase;use pocketmine\scheduler\Task;use pocketmine\Player;use pocketmine\utils\Config;use pocketmine\utils\TextFormat;use pocketmine\item\Item;use pocketmine\math\Vector3;use PowerNick\NickAPI\NickAPI;use PowerNick\PowerNick;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->Info("the ppppp enabled LOL"); $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10); $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20); $this->getServer()->getNetwork()->setName(TextFormat::BOLD . TextFormat::GREEN . "MineLegends"); $this->getServer()->getDefaultLevel()->setTime(1000); $this->getServer()->getDefaultLevel()->stopTime(); } public function onDisable(){ $this->getLogger()->Info("the ppppp has fucking error LOL"); } public function onJoin(PlayerJoinEvent $ev) { $player = $ev->getPlayer(); $player->getInventory()->setItem(1, Item::get(330)->setCustomName("§l§1Info")); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { if($sender instanceof Player){ switch($cmd->getName()){ case "hub"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); return true; case "lobby"; $item = Item::get(330,0,1); $inv = $sender->getInventory(); $item->setCustomName("§l§1Info"); $inv->addItem($item); return true; } } return true; } public function onInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $in = $player->getInventory()->getItemInHand()->getCustomName(); if ($in == "§l§1Info") { $this->getServer()->dispatchCommand($player, ""); } }}