Skip to content

Commit

Permalink
Make itemscript recipes allow m@ prefixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Oct 19, 2013
1 parent 93742bd commit fd9c1b3
Showing 1 changed file with 8 additions and 11 deletions.
@@ -1,9 +1,9 @@
package net.aufdemrand.denizen.scripts.containers.core;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.aufdemrand.denizen.objects.dMaterial;
import net.aufdemrand.denizen.objects.dNPC;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.scripts.ScriptRegistry;
Expand All @@ -16,7 +16,6 @@
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;

Expand Down Expand Up @@ -56,41 +55,39 @@ public class ItemScriptContainer extends ScriptContainer {
dNPC npc = null;
dPlayer player = null;
public boolean bound = false;
List<dItem> recipe = null;
List<dMaterial> recipe = null;

public ItemScriptContainer(ConfigurationSection configurationSection, String scriptContainerName) {
super(configurationSection, scriptContainerName);
ItemScriptHelper.item_scripts.put(getName(), this);
// Set Recipe
if (contains("RECIPE")) {
recipe = new ArrayList<dItem>();
recipe = new ArrayList<dMaterial>();
for (String recipeRow : getStringList("RECIPE")) {
recipeRow = TagManager.tag(player, npc, recipeRow);
String[] row = recipeRow.split("\\|", 3);
for (String material : row) {
recipe.add(recipe.size(), dItem.valueOf(material));
recipe.add(recipe.size(), dMaterial.valueOf(material));
}
}
ShapedRecipe shapedRecipe = new ShapedRecipe(getItemFrom().getItemStack());
shapedRecipe.shape("abc", "def", "ghi");
char x = 'a';
for (dItem material : recipe) {
if (!material.getItemStack().getType().name().equals("AIR"))
shapedRecipe.setIngredient(x, material.getItemStack().getData());
for (dMaterial material : recipe) {
if (!material.getMaterial().name().equals("AIR"))
shapedRecipe.setIngredient(x, material.getMaterialData());
x++;
}

Bukkit.getServer().addRecipe(shapedRecipe);
}
}



public dItem getItemFrom() {
return getItemFrom(null, null);
}

public List<dItem> getRecipe() {
public List<dMaterial> getRecipe() {
return recipe;
}

Expand Down

0 comments on commit fd9c1b3

Please sign in to comment.