Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. package me.eightbitfusion;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.logging.Logger;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.enchantments.Enchantment;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.player.PlayerItemConsumeEvent;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.inventory.ShapedRecipe;
  15. import org.bukkit.inventory.ShapelessRecipe;
  16. import org.bukkit.inventory.meta.ItemMeta;
  17. import org.bukkit.plugin.PluginDescriptionFile;
  18. import org.bukkit.plugin.java.JavaPlugin;
  19. import org.bukkit.potion.PotionEffect;
  20. import org.bukkit.potion.PotionEffectType;
  21.  
  22. public class Tiered_Apples extends JavaPlugin implements Listener {
  23.  
  24. public final Logger logger = Logger.getLogger("Minecraft");
  25. public static Tiered_Apples plugin;
  26.  
  27. @Override
  28. public void onEnable() {
  29.  
  30. PluginDescriptionFile pdf = this.getDescription();
  31. this.logger.info(pdf.getName() + " Version " + pdf.getVersion()
  32. + " has been enabled.");
  33.  
  34. ShapedRecipe ferrousApple = new ShapedRecipe(new ItemStack(
  35. getCustomItem("IronApple")));
  36. ferrousApple.shape("iii", "iai", "iii");
  37. ferrousApple.setIngredient('i', Material.IRON_BLOCK);
  38. ferrousApple.setIngredient('a', Material.APPLE);
  39. Bukkit.getServer().addRecipe(ferrousApple);
  40.  
  41. ShapedRecipe diamondApple = new ShapedRecipe(new ItemStack(
  42. getCustomItem("DiamondApple")));
  43. diamondApple.shape("###", "#$#", "###");
  44. diamondApple.setIngredient('#', Material.DIAMOND);
  45. diamondApple.setIngredient('$', Material.APPLE);
  46. Bukkit.getServer().addRecipe(diamondApple);
  47.  
  48. ShapelessRecipe crystallizedApple = new ShapelessRecipe(new ItemStack(
  49. getCustomItem("CrystallizedApple")))
  50. .addIngredient(Material.DIAMOND_BLOCK)
  51. .addIngredient(Material.DIAMOND_BLOCK)
  52. .addIngredient(Material.APPLE);
  53. Bukkit.getServer().addRecipe(crystallizedApple);
  54. }
  55.  
  56. @Override
  57. public void onDisable() {
  58. PluginDescriptionFile pdf = this.getDescription();
  59. this.logger.info(pdf.getName() + " Version " + pdf.getVersion()
  60. + " has been disabled.");
  61. }
  62.  
  63. @EventHandler
  64. public void onPlayerItemConsumeEvent(final PlayerItemConsumeEvent ev) {
  65. Player p=ev.getPlayer();
  66. if (p.getItemInHand().getType() == Material.GOLDEN_APPLE) {
  67. if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.ITALIC + "Ferrous Apple")) {
  68. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,160, 2));
  69.  
  70. } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Diamond Apple")) {
  71. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200, 2));
  72.  
  73. } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Crystallized Apple")) {
  74. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,460, 2));
  75. }
  76. }
  77. }
  78.  
  79. public ItemStack getCustomItem(String item) {
  80. ItemStack is = null;
  81. ItemMeta im = null;
  82. ArrayList<String> lore;
  83. if (item.equals("IronApple")) {
  84. is = new ItemStack(Material.GOLDEN_APPLE);
  85. im = is.getItemMeta();
  86. im.setDisplayName(ChatColor.ITALIC + "Ferrous Apple");
  87. lore = new ArrayList<String>();
  88. lore.add(ChatColor.GOLD + "This iron plated apple heals 3 hearts!");
  89. im.setLore(lore);
  90. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  91. is.setItemMeta(im);
  92. is.removeEnchantment(Enchantment.ARROW_DAMAGE);
  93. return is;
  94. } else if (item.equals("DiamondApple")) {
  95. is = new ItemStack(Material.GOLDEN_APPLE);
  96. im = is.getItemMeta();
  97. im.setDisplayName(ChatColor.AQUA + "Diamond Apple");
  98. lore = new ArrayList<String>();
  99. lore.add(ChatColor.GOLD
  100. + "This diamond coated apple heals 4 hearts!");
  101. im.setLore(lore);
  102. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  103. is.setItemMeta(im);
  104. is.removeEnchantment(Enchantment.ARROW_DAMAGE);
  105. return is;
  106. } else if (item.equals("CrystallizedApple")) {
  107. is = new ItemStack(Material.GOLDEN_APPLE);
  108. im = is.getItemMeta();
  109. im.setDisplayName(ChatColor.AQUA + "Crystallized Apple");
  110. lore = new ArrayList<String>();
  111. lore.add(ChatColor.GOLD + "This luminous apple heals 9 hearts!");
  112. im.setLore(lore);
  113. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  114. is.setItemMeta(im);
  115. is.removeEnchantment(Enchantment.ARROW_DAMAGE);
  116. return is;
  117.  
  118. }
  119. return is;
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement