Files
src
build.gradle
settings.gradle
Code
7 271
src/main/java/com/kodari/gravescepter/RevenantsGravescepterPlugin.java
package com.kodari.gravescepter;
import com.kodari.gravescepter.command.GravescepterCommand;
import com.kodari.gravescepter.item.GravescepterItem;
import com.kodari.gravescepter.listener.GravescepterListener;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public final class RevenantsGravescepterPlugin extends JavaPlugin {
@Override
public void onEnable() {
GravescepterItem item = new GravescepterItem(this);
getServer().getPluginManager().registerEvents(new GravescepterListener(this, item), this);
if (getCommand("gravescepter") != null) {
GravescepterCommand command = new GravescepterCommand(item);
getCommand("gravescepter").setExecutor(command);
getCommand("gravescepter").setTabCompleter(command);
}
registerRecipe(item);
}
private void registerRecipe(GravescepterItem item) {
Material netheriteIngot = XMaterial.matchXMaterial("NETHERITE_INGOT")
.map(XMaterial::parseMaterial)
.orElseThrow(() -> new IllegalStateException("Netherite ingot is unavailable"));
Material diamondBlock = XMaterial.matchXMaterial("DIAMOND_BLOCK")
.map(XMaterial::parseMaterial)
.orElseThrow(() -> new IllegalStateException("Diamond block is unavailable"));
Material mace = XMaterial.matchXMaterial("MACE")
.map(XMaterial::parseMaterial)
.orElseThrow(() -> new IllegalStateException("Mace is unavailable"));
NamespacedKey recipeKey = new NamespacedKey(this, "revenants_gravescepter");
ShapedRecipe recipe = new ShapedRecipe(recipeKey, item.create());
recipe.shape("NDN", "DMD", "NDN");
recipe.setIngredient('N', netheriteIngot);
recipe.setIngredient('D', diamondBlock);
recipe.setIngredient('M', mace);
getServer().addRecipe(recipe);
}
}