Files
src
build.gradle
Code
7 455
src/main/java/com/restricteddebugstick/RestrictedDebugStick.java
package com.restricteddebugstick;
import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class RestrictedDebugStick extends JavaPlugin {
private DebugStickManager debugStickManager;
private NamespacedKey debugStickKey;
@Override
public void onEnable() {
saveDefaultConfig();
this.debugStickKey = new NamespacedKey(this, "restricted_debug_stick");
this.debugStickManager = new DebugStickManager(this);
registerRecipe();
getServer().getPluginManager().registerEvents(new DebugStickListener(this), this);
getCommand("rdstick").setExecutor(new ReloadCommand(this));
getLogger().info("RestrictedDebugStick has been enabled!");
}
@Override
public void onDisable() {
getLogger().info("RestrictedDebugStick has been disabled!");
}
private void registerRecipe() {
XMaterial.matchXMaterial("DEBUG_STICK").ifPresent(debugStick -> {
XMaterial.matchXMaterial("STICK").ifPresent(stick -> {
XMaterial.matchXMaterial("NETHER_STAR").ifPresent(netherStar -> {
ShapedRecipe recipe = new ShapedRecipe(
new NamespacedKey(this, "restricted_debug_stick_recipe"),
debugStickManager.createDebugStick()
);
recipe.shape(" N ", " S ", " ");
recipe.setIngredient('N', netherStar.parseMaterial());
recipe.setIngredient('S', stick.parseMaterial());
try {
Bukkit.addRecipe(recipe);
getLogger().info("Registered crafting recipe: Stick + Nether Star = Restricted Debug Stick");
} catch (Exception e) {
getLogger().warning("Failed to register recipe: " + e.getMessage());
}
});
});
});
}
public String getMessage(String path) {
String prefix = getConfig().getString("messages.prefix", "&6[DebugStick] &r");
String message = getConfig().getString("messages." + path, path);
return colorize(prefix + message);
}
public String colorize(String text) {
return org.bukkit.ChatColor.translateAlternateColorCodes('&', text);
}
}