Recipe creation for ram

This commit is contained in:
Aubri Seebauer committed 2023-05-02 14:10:10 -04:00
1 parent 0f167ef6c3
commit 994509b823
3 files changed
+62 -5

No files matched your search

@@ -229,13 +229,12 @@ public class CommandHelper {
* @param args command args
* @return success
*/
protected static boolean logCommand(CommandSender sender, String label, String[] args) {
protected static void logCommand(CommandSender sender, String label, String[] args) {
StringBuilder log = new StringBuilder(label);
for (String s : args) {
log.append(" ").append(s);
}
Main.warLogger.log(Helper.chatLabel() + sender.getName() + " ran command: " + log.toString());
return true;
}
/**
@@ -24,7 +24,7 @@ public class WarItems {
public WarItems() {
Main.warLogger.log(Helper.chatLabel() + "Registering AlathraWar items.");
itemRegistry.put(registryName("ram"), getBatteringRam());
itemRegistry.put(registryName("ram"), batteringRam());
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar items.");
}
@@ -34,7 +34,7 @@ public class WarItems {
* @param item
* @return
*/
private static String registryName(String item) {
public static String registryName(String item) {
return namespace + ":" + item;
}
@@ -62,7 +62,7 @@ public class WarItems {
}
public ItemStack getBatteringRam() {
public ItemStack batteringRam() {
ItemStack ram = new ItemStack(Material.WOODEN_HOE);
ItemMeta meta = ram.getItemMeta();
@@ -1,4 +1,62 @@
package me.ShermansWorld.AlathraWar.items;
import me.ShermansWorld.AlathraWar.AlathraWarLogger;
import me.ShermansWorld.AlathraWar.Helper;
import me.ShermansWorld.AlathraWar.Main;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.Plugin;
import java.util.HashMap;
public class WarRecipes {
private static final HashMap<String, Recipe> recipeRegistry = new HashMap<>();
public WarRecipes() {
Main.warLogger.log(Helper.chatLabel() + "Registering AlathraWar recipes.");
recipeRegistry.put(WarItems.registryName("ram"), ramRecipe());
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar recipes.");
}
public static HashMap<String, Recipe> getRecipeRegistry() {
return recipeRegistry;
}
/**
* returns the associated itemstack with the item key, use for finding without namespace
* @param registryName recipe name without namespace
* @return recipe
*/
public static Recipe getOrNull(String registryName) {
return recipeRegistry.get(WarItems.registryName(registryName));
}
/**
* returns the associated itemstack with the item key, use for finding with namespace
* @param registryName registry name including namespace
* @return recipe
*/
public static Recipe getOrNullNamespace(String registryName) {
return recipeRegistry.get(registryName);
}
public Recipe ramRecipe() {
ItemStack output = WarItems.getOrNull("ram");
NamespacedKey key = new NamespacedKey((Plugin) Main.getInstance(), "ram");
ShapedRecipe recipe = new ShapedRecipe(key, output);
recipe.shape(new String[] { "$@$", "B##"});
recipe.setIngredient('@', Material.STICK);
recipe.setIngredient('$', Material.IRON_INGOT);
recipe.setIngredient('B', Material.IRON_BLOCK);
recipe.setIngredient('%', Material.OAK_LOG);
return recipe;
}
}