Custom Crafts Plugin help

Hello , i would like to get some help. im a new PHP coder and im having some issues with finding any problems there could be
1 Reply
!  KingHELP
! KingHELP10mo ago
Im trying to create a MCPE plugin for custom crafting but i cant figure out the probem why it doesnt work , here is my code <?php namespace customcrafts; use pocketmine\command\CommandSender; use pocketmine\command\Command; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\inventory\BigShapedRecipe; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\Item; use pocketmine\utils\Config; class CustomCrafts extends PluginBase implements Listener { public function onEnable() { $this->saveDefaultConfig(); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->registerRecipes(); } public function registerRecipes() { $config = $this->getConfig()->getAll(); if (isset($config['recipes']['armor'])) { $this->registerRecipeGroup($config['recipes']['armor']); } if (isset($config['recipes']['weapons'])) { $this->registerRecipeGroup($config['recipes']['weapons']); } if (isset($config['recipes']['tools'])) { $this->registerRecipeGroup($config['recipes']['tools']); } } private function registerRecipeGroup($recipes) { foreach ($recipes as $recipe) { $id = $recipe['id']; $name = $recipe['name']; $pattern = $recipe['pattern']; $ingredients = $recipe['ingredients']; $enchantment = $recipe['enchantment'] ?? 0; $this->registerRecipe($id, $name, $pattern, $ingredients, $enchantment); } } private function registerRecipe($id, $name, $pattern, $ingredients, $enchantmentLevel = 0) { $item = Item::get($id, 0, 1); $item->setCustomName("§r§aEmerald " . $name); $item->addEnchantment(Enchantment::getEnchantment(0)->setLevel($enchantmentLevel)); $craftingRecipe = new BigShapedRecipe($item, ...$pattern); foreach ($ingredients as $ingredient => $ingredientItem) { $craftingRecipe->setIngredient($ingredient, Item::get(...$ingredientItem)); } $this->getServer()->getCraftingManager()->registerRecipe($craftingRecipe); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { // Handle your commands here if needed return true; } }
Want results from more Discord servers?
Add your server