PHP code example of nglam2911 / invcraft
1. Go to this page and download the library: Download nglam2911/invcraft library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nglam2911 / invcraft example snippets
use NgLam2911\InvCraft\crafting\Recipe;
use NgLam2911\InvCraft\InvCraft;
$recipeManager = InvCraft::getInstance()->getRecipeManager();
// Create a new recipe
$recipe = new Recipe(<args here>);
$recipeManager->addRecipe($recipe);
// Remove a recipe
$recipeManager->removeRecipe(<recipe name>);
// Get a recipe
$result = $recipeManager->getRecipe(<recipe name>);
use NgLam2911\InvCraft\event\InvCraftItemEvent;
// EventsListener.php
public function onCraft(InvCraftItemEvent $event) {
$player = $event->getPlayer();
$recipe = $event->getRecipe();
$result = $event->getResult();
// Do something here
}