Skip to content

Commit

Permalink
Added a way to disable Notch apples.
Browse files Browse the repository at this point in the history
Closes #3.
  • Loading branch information
AmauryCarrade committed Aug 9, 2014
1 parent 2c85fb7 commit 2b94b14
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/me/azenet/UHPlugin/UHPluginListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -330,6 +331,30 @@ public void onPreCraftEvent(PrepareItemCraftEvent ev) {
return;
}

// Enchanted golden apple - the same technique does not work, this is a workaround
if(p.getConfig().getBoolean("gameplay-changes.goldenApple.disableNotchApples")) {
if(ev.getInventory().getResult().getType() == Material.GOLDEN_APPLE) {
if(recipe instanceof ShapelessRecipe) {
for(ItemStack item : ((ShapelessRecipe) recipe).getIngredientList()) {
if(item.getType() == Material.GOLD_BLOCK) {
// There is a gold block in a recipe for a golden apple - NOPE
ev.getInventory().setResult(new ItemStack(Material.AIR));
return;
}
}
}
else { // shaped recipe
for(ItemStack item : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if(item.getType() == Material.GOLD_BLOCK) {
// There is a gold block in a recipe for a golden apple - NOPE NOPE NOPE
ev.getInventory().setResult(new ItemStack(Material.AIR));
return;
}
}
}
}
}


/** Adds a lore to the golden apples crafted from a head **/

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ gameplay-changes:
notch: 180
fromNormalHead: 4
fromNotchHead: 180

disableNotchApples: false

disableEnderpearlsDamages: true

Expand Down

0 comments on commit 2b94b14

Please sign in to comment.