Creating a Custom Material Loader
In this section, you'll learn how to define a custom material loader. This is useful if you want to dynamically generate items that aren't just simple Material.valueOf(...) items.
Goal
Step 1: Create the Material Loader Class
import fr.maxlego08.menu.api.loader.MaterialLoader;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ExampleMaterialLoader extends MaterialLoader {
public ExampleMaterialLoader() {
super("example-material");
}
@Override
public ItemStack load(Player player, YamlConfiguration yamlConfiguration, String path, String materialString) {
return new ItemStack(Material.DIAMOND);
}
}Constructor Explained
Step 2: Register the Material Loader
Step 3: Use It in a Configuration
Result
Last updated