Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 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. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  35.  
  36. ShapedRecipe ferrousApple = new ShapedRecipe(new ItemStack(
  37. getCustomItem("IronApple")));
  38. ferrousApple.shape("iii", "iai", "iii");
  39. ferrousApple.setIngredient('i', Material.IRON_BLOCK);
  40. ferrousApple.setIngredient('a', Material.APPLE);
  41. Bukkit.getServer().addRecipe(ferrousApple);
  42.  
  43. ShapedRecipe diamondApple = new ShapedRecipe(new ItemStack(
  44. getCustomItem("DiamondApple")));
  45. diamondApple.shape("###", "#$#", "###");
  46. diamondApple.setIngredient('#', Material.DIAMOND);
  47. diamondApple.setIngredient('$', Material.APPLE);
  48. Bukkit.getServer().addRecipe(diamondApple);
  49.  
  50. ShapelessRecipe crystallizedApple = new ShapelessRecipe(new ItemStack(
  51. getCustomItem("CrystallizedApple")))
  52. .addIngredient(Material.DIAMOND_BLOCK)
  53. .addIngredient(Material.DIAMOND_BLOCK)
  54. .addIngredient(Material.APPLE);
  55. Bukkit.getServer().addRecipe(crystallizedApple);
  56. }
  57.  
  58. @Override
  59. public void onDisable() {
  60. PluginDescriptionFile pdf = this.getDescription();
  61. this.logger.info(pdf.getName() + " Version " + pdf.getVersion()
  62. + " has been disabled.");
  63. }
  64.  
  65. @EventHandler
  66. public void onPlayerItemConsume(PlayerItemConsumeEvent ev) {
  67. Player p=ev.getPlayer();
  68. p.removePotionEffect(PotionEffectType.REGENERATION);
  69. if (p.getItemInHand().getType() == Material.GOLDEN_APPLE) {
  70. if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.ITALIC + "Ferrous Apple")) {
  71. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,160, 2));
  72.  
  73. } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Diamond Apple")) {
  74. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200, 2));
  75.  
  76. } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Crystallized Apple")) {
  77. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,460, 2));
  78. }
  79. }
  80. }
  81.  
  82. public ItemStack getCustomItem(String item) {
  83. ItemStack is = null;
  84. ItemMeta im = null;
  85. ArrayList<String> lore;
  86. if (item.equals("IronApple")) {
  87. is = new ItemStack(Material.GOLDEN_APPLE);
  88. im = is.getItemMeta();
  89. im.setDisplayName(ChatColor.ITALIC + "Ferrous Apple");
  90. lore = new ArrayList<String>();
  91. lore.add(ChatColor.GOLD + "This iron plated apple heals 3 hearts!");
  92. im.setLore(lore);
  93. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  94. is.setItemMeta(im);
  95. return is;
  96. } else if (item.equals("DiamondApple")) {
  97. is = new ItemStack(Material.GOLDEN_APPLE);
  98. im = is.getItemMeta();
  99. im.setDisplayName(ChatColor.AQUA + "Diamond Apple");
  100. lore = new ArrayList<String>();
  101. lore.add(ChatColor.GOLD
  102. + "This diamond coated apple heals 4 hearts!");
  103. im.setLore(lore);
  104. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  105. is.setItemMeta(im);
  106. return is;
  107. } else if (item.equals("CrystallizedApple")) {
  108. is = new ItemStack(Material.GOLDEN_APPLE);
  109. im = is.getItemMeta();
  110. im.setDisplayName(ChatColor.AQUA + "Crystallized Apple");
  111. lore = new ArrayList<String>();
  112. lore.add(ChatColor.GOLD + "This luminous apple heals 9 hearts!");
  113. im.setLore(lore);
  114. is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
  115. is.setItemMeta(im);
  116. return is;
  117.  
  118. }
  119. return is;
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement