Not sure what I'm doing wrong. I have never messed with item names or lores, so sorry for any nooby mistakes. This is the listener class where I tried to add a display name/lore. I know how to put it in someone inventory so don't tell me that, what I need to know how to do is to make this display name/lore "globalize" so for example, if I grew wheat and I broke the wheat the wheat that I grew would also have the display name/lore of "weed" Thanks! Code:java import java.util.ArrayList;import java.util.List; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Material;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.Action;import org.bukkit.event.player.PlayerInteractEvent;import org.bukkit.inventory.Inventory;import org.bukkit.inventory.ItemStack;import org.bukkit.inventory.meta.ItemMeta; public class DrugListener implements Listener{ public void ItemLores(){ ItemStack item = new ItemStack(Material.WHEAT); ItemMeta im = item.getItemMeta(); im.setDisplayName(ChatColor.DARK_GREEN + "Weed"); List<String> loreList = new ArrayList<String>(); loreList.add(ChatColor.GREEN + "Right click to smoke!");//This is the first line of lore im.setLore(loreList); item.setItemMeta(im); Bukkit.broadcastMessage("ItemLores method is working!"); } @EventHandler public void onDrugUse(PlayerInteractEvent event){ ItemLores(); Player player = (Player) event.getPlayer(); if(player.getItemInHand().getType() == Material.WHEAT){ if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK){ player.sendMessage(ChatColor.RED + "This is a test! :D"); } } }}
afaik, there is no way to "globalize" it like you want. What i do for my vineyard plugin: get the block break evet, get the drops and replace it with my custom itemstack with the correct name(or lore)
Why not use a plugin that already exists? It uses packets to accomplish the goal you desire. http://dev.bukkit.org/bukkit-plugins/itemrenamer/
Hi, i am mydes friend and because? Whats the fun of downloading a plugin, the fun is about making it urself and be happy. That u actually made something thats cool urself. Btw myde ill write some code for u Sorry man, couldnt figure it outD: EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Well the plugin in question was written by my friend meiskam (maker of PlayerHeads). That's why I suggested it. Oh well.