Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.eightbitfusion;
- import java.util.ArrayList;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerItemConsumeEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.ShapedRecipe;
- import org.bukkit.inventory.ShapelessRecipe;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class Tiered_Apples extends JavaPlugin implements Listener {
- public final Logger logger = Logger.getLogger("Minecraft");
- public static Tiered_Apples plugin;
- @Override
- public void onEnable() {
- PluginDescriptionFile pdf = this.getDescription();
- this.logger.info(pdf.getName() + " Version " + pdf.getVersion()
- + " has been enabled.");
- ShapedRecipe ferrousApple = new ShapedRecipe(new ItemStack(
- getCustomItem("IronApple")));
- ferrousApple.shape("iii", "iai", "iii");
- ferrousApple.setIngredient('i', Material.IRON_BLOCK);
- ferrousApple.setIngredient('a', Material.APPLE);
- Bukkit.getServer().addRecipe(ferrousApple);
- ShapedRecipe diamondApple = new ShapedRecipe(new ItemStack(
- getCustomItem("DiamondApple")));
- diamondApple.shape("###", "#$#", "###");
- diamondApple.setIngredient('#', Material.DIAMOND);
- diamondApple.setIngredient('$', Material.APPLE);
- Bukkit.getServer().addRecipe(diamondApple);
- ShapelessRecipe crystallizedApple = new ShapelessRecipe(new ItemStack(
- getCustomItem("CrystallizedApple")))
- .addIngredient(Material.DIAMOND_BLOCK)
- .addIngredient(Material.DIAMOND_BLOCK)
- .addIngredient(Material.APPLE);
- Bukkit.getServer().addRecipe(crystallizedApple);
- }
- @Override
- public void onDisable() {
- PluginDescriptionFile pdf = this.getDescription();
- this.logger.info(pdf.getName() + " Version " + pdf.getVersion()
- + " has been disabled.");
- }
- @EventHandler
- public void onPlayerItemConsumeEvent(final PlayerItemConsumeEvent ev) {
- Player p=ev.getPlayer();
- if (p.getItemInHand().getType() == Material.GOLDEN_APPLE) {
- if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.ITALIC + "Ferrous Apple")) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,160, 2));
- } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Diamond Apple")) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200, 2));
- } else if (p.getItemInHand().getItemMeta().getDisplayName()==(ChatColor.AQUA + "Crystallized Apple")) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,460, 2));
- }
- }
- }
- public ItemStack getCustomItem(String item) {
- ItemStack is = null;
- ItemMeta im = null;
- ArrayList<String> lore;
- if (item.equals("IronApple")) {
- is = new ItemStack(Material.GOLDEN_APPLE);
- im = is.getItemMeta();
- im.setDisplayName(ChatColor.ITALIC + "Ferrous Apple");
- lore = new ArrayList<String>();
- lore.add(ChatColor.GOLD + "This iron plated apple heals 3 hearts!");
- im.setLore(lore);
- is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
- is.setItemMeta(im);
- is.removeEnchantment(Enchantment.ARROW_DAMAGE);
- return is;
- } else if (item.equals("DiamondApple")) {
- is = new ItemStack(Material.GOLDEN_APPLE);
- im = is.getItemMeta();
- im.setDisplayName(ChatColor.AQUA + "Diamond Apple");
- lore = new ArrayList<String>();
- lore.add(ChatColor.GOLD
- + "This diamond coated apple heals 4 hearts!");
- im.setLore(lore);
- is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
- is.setItemMeta(im);
- is.removeEnchantment(Enchantment.ARROW_DAMAGE);
- return is;
- } else if (item.equals("CrystallizedApple")) {
- is = new ItemStack(Material.GOLDEN_APPLE);
- im = is.getItemMeta();
- im.setDisplayName(ChatColor.AQUA + "Crystallized Apple");
- lore = new ArrayList<String>();
- lore.add(ChatColor.GOLD + "This luminous apple heals 9 hearts!");
- im.setLore(lore);
- is.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 0);
- is.setItemMeta(im);
- is.removeEnchantment(Enchantment.ARROW_DAMAGE);
- return is;
- }
- return is;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement