Skip to content

Commit

Permalink
reduce risk of nonsense items on all fronts!
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 10, 2017
1 parent 1432284 commit 160ba7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Expand Up @@ -137,7 +137,7 @@ public void onRecipeFormed(PrepareItemCraftEvent event) {
result = new dItem(eRecipe.getResult());
recipe = new dList();
for (ItemStack itemStack : inventory.getMatrix()) {
if (itemStack != null) {
if (itemStack != null && itemStack.getType() != Material.AIR) {
recipe.add(new dItem(itemStack).identify());
}
else {
Expand Down
23 changes: 10 additions & 13 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dItem.java
Expand Up @@ -235,7 +235,7 @@ public dItem(int type, int qty) {
}

public dItem(ItemStack item) {
if (item == null) {
if (item == null || item.getType() == Material.AIR) {
this.item = new ItemStack(Material.AIR, 0);
}
else {
Expand Down Expand Up @@ -509,25 +509,22 @@ public String debug() {
@Override
public String identify() {

if (item == null) {
if (item == null || item.getType() == Material.AIR) {
return "i@air";
}

if (item.getTypeId() != 0) {

// If saved item, return that
if (isUnique()) {
return "i@" + NotableManager.getSavedId(this) + PropertyParser.getPropertiesString(this);
}
// If saved item, return that
if (isUnique()) {
return "i@" + NotableManager.getSavedId(this) + PropertyParser.getPropertiesString(this);
}

// If not a saved item, but is a custom item, return the script id
else if (isItemscript()) {
return "i@" + getScriptName() + PropertyParser.getPropertiesString(this);
}
// If not a saved item, but is a custom item, return the script id
else if (isItemscript()) {
return "i@" + getScriptName() + PropertyParser.getPropertiesString(this);
}

// Else, return the material name
if ((item.getDurability() >= 16 || item.getDurability() < 0) && item.getType() != Material.AIR) {
else if ((item.getDurability() >= 16 || item.getDurability() < 0) && item.getType() != Material.AIR) {
return "i@" + getMaterial().realName() + "," + item.getDurability() + PropertyParser.getPropertiesString(this);
}
return "i@" + getMaterial().identify().replace("m@", "") + PropertyParser.getPropertiesString(this);
Expand Down

0 comments on commit 160ba7a

Please sign in to comment.