Lore help

Discussion in 'Bukkit Help' started by Peter_Higgs, Mar 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Peter_Higgs

    hey guys I have been working on a throwing knife plugin for a friend and I have given a stick and a blaze rod custom names and lore. I set up an event handler to fire a snowball when ONLY the stick or blaze rod with custom names are interacted with. Here is my code

    Code:java
    1. package me.OmDalvi.ThrowingKnives;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Effect;
    9. import org.bukkit.Material;
    10. import org.bukkit.enchantments.Enchantment;
    11. import org.bukkit.entity.*;
    12. import org.bukkit.event.EventHandler;
    13. import org.bukkit.event.Listener;
    14. import org.bukkit.event.block.Action;
    15. import org.bukkit.event.player.PlayerInteractEvent;
    16. import org.bukkit.inventory.ItemStack;
    17. import org.bukkit.inventory.ShapedRecipe;
    18. import org.bukkit.inventory.meta.ItemMeta;
    19. import org.bukkit.plugin.java.JavaPlugin;
    20.  
    21. public class Main extends JavaPlugin implements Listener {
    22.  
    23. ItemStack knive = new ItemStack(Material.STICK, 16);
    24. ItemStack fireKnive = new ItemStack(Material.BLAZE_ROD, 16);
    25.  
    26. @Override
    27. public void onEnable(){
    28.  
    29. //Meta Data
    30. ItemMeta fireKniveMeta = fireKnive.getItemMeta();
    31. //lore
    32. List<String> Firelore = new ArrayList<String>();
    33. Firelore.add(ChatColor.GOLD +"This is a disguised throwing knife.");
    34. Firelore.add(ChatColor.GREEN +"Boom, Boom, Fia Powa!!!");
    35. Firelore.add(ChatColor.BLUE +"+ ∞ damage");
    36. fireKniveMeta.setLore(Firelore);
    37. //lore end
    38. //rename
    39. fireKniveMeta.setDisplayName(ChatColor.RED +"Throwing" +ChatColor.BLUE +"Knive");
    40. //rename ends
    41. //enchants
    42. fireKniveMeta.addEnchant(Enchantment.KNOCKBACK, 100, true);
    43. fireKniveMeta.addEnchant(Enchantment.FIRE_ASPECT, 100, true);
    44. fireKniveMeta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 100, true);
    45. fireKniveMeta.addEnchant(Enchantment.DAMAGE_ALL, 100, true);
    46. //enchants end
    47. knive.setItemMeta(fireKniveMeta);
    48. //Meta Data end
    49. //Recipe
    50. ShapedRecipe fireKniveRecipe = new ShapedRecipe(knive);
    51. fireKniveRecipe.shape("###","#I#","#S#");
    52. fireKniveRecipe.setIngredient('I', Material.IRON_INGOT);
    53. fireKniveRecipe.setIngredient('S', Material.BLAZE_ROD);
    54. //Recipe End
    55.  
    56. //Meta Data
    57. ItemMeta kniveMeta = knive.getItemMeta();
    58. //lore
    59. List<String> lore = new ArrayList<String>();
    60. lore.add(ChatColor.GOLD +"This is a disguised throwing knife.");
    61. lore.add(ChatColor.GREEN +":) :) :) :) :) :) :) :) :) :) :)");
    62. lore.add(ChatColor.BLUE +"+ ∞ damage");
    63. kniveMeta.setLore(lore);
    64. //lore end
    65. //rename
    66. kniveMeta.setDisplayName(ChatColor.AQUA +"Throwing" +ChatColor.BLUE +"Knive");
    67. //rename ends
    68. //enchants
    69. kniveMeta.addEnchant(Enchantment.KNOCKBACK, 100, true);
    70. kniveMeta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 100, true);
    71. kniveMeta.addEnchant(Enchantment.DAMAGE_ALL, 100, true);
    72. //enchants end
    73. knive.setItemMeta(kniveMeta);
    74. //Meta Data end
    75. //Recipe
    76. ShapedRecipe kniveRecipe = new ShapedRecipe(knive);
    77. kniveRecipe.shape("###","#I#","#S#");
    78. kniveRecipe.setIngredient('I', Material.IRON_INGOT);
    79. kniveRecipe.setIngredient('S', Material.STICK);
    80. //Recipe End
    81. Bukkit.getServer().addRecipe(kniveRecipe);
    82.  
    83. //Events
    84. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    85. //Events end
    86.  
    87. }
    88.  
    89. @Override
    90. public void onDisable(){
    91. Bukkit.getServer().clearRecipes();
    92. }
    93.  
    94. @EventHandler
    95. public void onPlayerInteract(final PlayerInteractEvent e) {
    96. if(!(e.getAction() == Action.RIGHT_CLICK_AIR)) return;
    97. if(e.getItem().getType() == Material.BLAZE_ROD){
    98. Snowball s = e.getPlayer().launchProjectile(Snowball.class);
    99. s.getWorld().playEffect(e.getPlayer().getLocation(), Effect.SMOKE, 10);
    100. }else if(e.getItem().getType() == Material.STICK){
    101. Snowball s = e.getPlayer().launchProjectile(Snowball.class);
    102. s.getWorld().playEffect(e.getPlayer().getLocation(), Effect.SMOKE, 10);
    103. }
    104. }
    105.  
    106. }


    Plz help as my friend wants it done in a week!!

    Bye!
     
  2. Offline

    JaguarJo

    antares330 likes this.
  3. Offline

    Peter_Higgs

    Ok I think I will. Thnx for the info.
     
Thread Status:
Not open for further replies.

Share This Page