Hello, I made a plugin that should should work like that... so i type the command /up (y) and i should get teleported to that y coordination and the plugin should place a glass block under my feet. I am getting some errors.. Please look over the whole main file and tell me what I am doing wrong. PHP: <?phpnamespace SJames\UpCommand;use pocketmine\Blocks;use pocketmine\level\Position;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\TextFormat as c;use pocketmine\Vector3;class Main extends PluginBase { public function onEnable(){ } public function onCommand(CommandSender $player, Command $cmd, String $label, array $args) :bool { switch($cmd->getName()){ case "up" ; if(!($player instanceof Player)){ $sender->sendMessage("Please run this command in-game."); }else{ $x = $player->getX(); $z = $player->getZ(); $level = $player->getLevel(); $y = $args[0]; if(is_numeric($y)) { $player->teleport(new Position($x, $y, $z)); $level->setBlock(new Position($x, $y-1, $z), new Glass(), false); } else { $sender->sendMessage("Usage: /up {y-coordinates}"); return true;}}}}}
PHP: [/COLOR][/SIZE][/LEFT][SIZE=4][COLOR=rgb(20, 20, 20)][LEFT]<?phpnamespace SJames\UpCommand;use pocketmine\Blocks;use pocketmine\level\Position;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\TextFormat as c;use pocketmine\Vector3;class Main extends PluginBase { public function onEnable(){ } public function onCommand(CommandSender $player, Command $cmd, String $label, array $args) :bool { switch($cmd->getName()){ case "up" ; if(!($player instanceof Player)){ $sender->sendMessage("Please run this command in-game."); }else{ $x = $player->getX(); $z = $player->getZ(); $level = $player->getLevel(); $y = $args[0]; if(is_numeric($y)) { $player->teleport(new Position($x, $y + 1, $z)); $level->setBlock(new Position($x, (int)$y, $z), Block::get(Block::GLASS), false); } else { $sender->sendMessage("Usage: /up {y-coordinates}"); return true;}}}}} block should be placed where value specified, to avoid bounds glitching, you teleport the player one block above the given value you should use Block::get() to get instances of blocks
Thanks. But is isn't working still. I do not understand.. the error says that the pocketmine\Block is missing but I have it "use pocketmine\blocks", "use pocketmine\block" doesn't work eather Error: "Class 'pocketmine\Block' not found" (EXCEPTION) in "plugins/UpCommand/src/SJames/UpCommand/Main" at line 29