本文整理匯總了Java中org.bukkit.inventory.meta.ItemMeta.setLore方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemMeta.setLore方法的具體用法?Java ItemMeta.setLore怎麽用?Java ItemMeta.setLore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.ItemMeta
的用法示例。
在下文中一共展示了ItemMeta.setLore方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
/**
* Adds lore after the index of a lore line
*
* @param index index
* @param lore lore
* @return builder
*/
public ItemStackBuilder addLore(int index, String... lore) {
final ItemMeta itemMeta = this.getItemMeta();
final List<String> data = new ArrayList<>();
for (int i = 0; i < itemMeta.getLore().size(); i++) {
data.add(itemMeta.getLore().get(0));
if (i == index) {
for (final String s : lore) {
data.add(ChatColor.translateAlternateColorCodes('&', s));
}
}
}
itemMeta.setLore(data);
this.setItemMeta(itemMeta);
return this;
}
示例2: bardKitGlass
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private ItemStack bardKitGlass(Player player) {
ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 4);
ItemMeta meta = stack.getItemMeta();
addGlow(stack);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&eBard &7Kit"));
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&7This kit contains:"));
lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Bard kit with Bard Materials!"));
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase this from store.hcriots.net"));
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
if(cooldowns.containsKey(player.getUniqueId())) {
if(cooldowns.get(player.getUniqueId()).containsKey("BardKit")) {
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("BardKit"), true, true)));
} else {
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
}
} else {
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
}
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
}
示例3: getWeapon
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T extends Weapon> ItemStack getWeapon(Class<T> weapon){
T weaponInst = (T) weaponCache.computeIfAbsent(weapon, k->MiniWynnPlugin.getInjector().getInstance(weapon));
weaponInst.getSpells().forEach(spell -> spellCache.put(spell.getPattern(), spell));
weaponCache.putIfAbsent(weapon, weaponInst);
ItemStack item = new ItemStack(
weaponInst.getMaterial(),
1,
weaponInst.getDamage()
);
ItemMeta meta = item.getItemMeta();
meta.setUnbreakable(true);
meta.setDisplayName(weaponInst.getName());
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE);
meta.setLore(weaponInst.getLore());
item.setItemMeta(meta);
return item;
}
示例4: isShardType
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private static boolean isShardType(ItemStack item, ItemStack type) {
if (item == null)
return false;
if (type == null)
return false;
if (item.getType() != type.getType())
return false;
if (!item.hasItemMeta())
return false;
ItemMeta im = item.getItemMeta();
if (!im.hasDisplayName())
return false;
if (im.getDisplayName().equals(type.getItemMeta().getDisplayName())) {
im.setLore(type.getItemMeta().getLore());
item.setItemMeta(im);
return true;
}
return false;
}
示例5: onCommand
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
PlayerFaction playerFaction = HCF.getPlugin().getFactionManager().getPlayerFaction(player);
this.factionManager = Bukkit.createInventory(null, 36, "Faction Management");
if (playerFaction == null) {
player.sendMessage(ChatColor.RED + "You don't have a faction");
return true;
}
if (playerFaction.getMember(player).getRole() == Role.LEADER) {
player.openInventory(factionManager);
for (Player p : playerFaction.getOnlinePlayers()) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta meta = skull.getItemMeta();
meta.setLore((Arrays.asList(new String[]{ChatColor.translateAlternateColorCodes('&',"&aRight click to &2&lDEMOTE &athis player."),
(ChatColor.translateAlternateColorCodes('&',"&aLeft click to &2&LPROMOTE &athis player.")),ChatColor.translateAlternateColorCodes('&',"&aMiddle click to make this person &2&lLEADER&a.")})));
meta.setDisplayName(p.getName());
skull.setItemMeta(meta);
factionManager.addItem(skull);
}
} else {
player.sendMessage(ChatColor.RED + "You are not a leader.");
}
return false;
}
示例6: refresh
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public void refresh(VPPlayer viewer, Inventory inv){
MenuLink ml = (MenuLink) ((inv.getHolder() instanceof MenuLink) ? inv.getHolder() : null);
for (int i = 1; i < icons.length; i++) {
if (icons[i] != null && !icons[i].isStatic()){
Icon icon = icons[i].getIcon(viewer);
if(icon == null) {
if(type == InventoryType.PLAYER) {
ItemStack[] memory = viewer.getInventory(false);
if(memory[i-1] != null) {
inv.setItem(i-1, memory[i-1]);
memory[i-1] = null;
viewer.setInventory(memory, false);
}
}else
inv.setItem(i-1, new ItemStack(Material.AIR));
continue;
}
if(icon.skullSelf()){
ItemStack item = inv.getItem(i-1);
if(item != null && item.getType() == Material.SKULL_ITEM){
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(icon.getLores(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
itemMeta.setDisplayName(icon.getName(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
((SkullMeta)itemMeta).setOwner(ml == null ? viewer.getName() : ml.getView().getName());
item.setItemMeta(itemMeta);
continue;
}
}
if(icon != null)
inv.setItem(i-1, icon.getItemstack(ml == null ? viewer : ml.getView(), viewer.getLanguage()));
}
}
}
示例7: setItem
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void setItem(String display, Material id, int data, int amount, List<String> lore, Map<Enchantment,Integer> enchants, int loc, Inventory inventory) {
ItemStack icon = new ItemStack(id, amount, (short) data);
ItemMeta iconmeta = icon.getItemMeta();
iconmeta.setDisplayName(display);
iconmeta.setLore(lore);
for(Object enchantitem : enchants.keySet()){
for(int level : enchants.values()) {
Enchantment enchant = (Enchantment) enchantitem;
iconmeta.addEnchant(enchant,level,false);
}
}
icon.setItemMeta(iconmeta);
inventory.setItem(loc, icon);
}
示例8: getArchivedItem
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack getArchivedItem() {
ItemStack is = new ItemStack(Material.PAPER);
ItemMeta im = is.getItemMeta();
/**
* Item:
*
* Name = Request #x
* Lore 1: Requested by: _name_
* Lore 2: Reason: reason
* Lore 3: Requested at: time
* Lore 4: Closed by: name
* Lore 5: Closed at: time
* Lore 6: Request was: accept/deny
*/
im.setDisplayName(Messager.color("&eRequest #" + id));
String temp = null;
if (accepted) {
temp = "&aAccepted";
} else if (denied) {
temp = "&cDenied";
}
im.setLore(Arrays.asList(Messager.color("&eRequested by: &7" + Bukkit.getOfflinePlayer(UUID.fromString(openerUUID)).getName()), Messager.color("&eReason: &7" + banReason),
Messager.color("&eRequested at: &7" + timeOpenedFormatted), Messager.color("&eClosed by: &7" + Bukkit.getOfflinePlayer(UUID.fromString(closerUUID)).getName()),
Messager.color("&eClosed at: &7" + timeClosedFormatted), Messager.color("&eRequest was: " + temp)));
is.setItemMeta(im);
return is;
}
示例9: formatItem
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack formatItem(ItemStack item, String name, List<String> ... lore){
List<String> lores = new ArrayList<>();
for (int i = 0; i < lore.length; i++) {
lores.addAll(lore[i]);
}
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lores);
item.setItemMeta(meta);
return item;
}
示例10: createItemKey
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static ItemStack createItemKey(Material type,short damage,String world,int x,int y,int z){
ItemStack is=new ItemStack(type,1,damage);
ItemMeta im=is.getItemMeta();
//set Key
im.setDisplayName(world+Long.toHexString(Long.parseLong((x+""+y+""+z+"").replace("-", "010"))));
im.setLore(Arrays.asList(world,x+"",y+"",z+""));
is.setItemMeta(im);
return is;
}
示例11: clearLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
/**
* Clears all lore from the itemStack
* @return builder
*/
public ItemStackBuilder clearLore() {
final ItemMeta itemMeta = this.getItemMeta();
itemMeta.setLore(new ArrayList<>());
this.setItemMeta(itemMeta);
return this;
}
示例12: setLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemWrapper setLore(String... lores) {
ItemMeta meta = getHandle().getItemMeta();
meta.setLore(asColorizeList(lores));
getHandle().setItemMeta(meta);
return this;
}
示例13: addToLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private static ItemStack addToLore(ItemStack i, String... toAdd){
List<String> lore = new ArrayList<>();
if (!lore.isEmpty()) lore.clear();
lore.addAll(i.getItemMeta().getLore());
for(String s : toAdd){
lore.add(s);
}
ItemMeta im = i.getItemMeta();
im.setLore(lore);
i.setItemMeta(im);
return i;
}
示例14: getItem
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@Override
public ItemStack getItem() {
ItemStack item = new ItemStack(Material.END_CRYSTAL);
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + getName());
lore.add(ChatColor.GRAY + getDescription());
lore.add(ChatColor.GRAY + "Rarity: " + getRarity().getName());
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(getRarity().getColor() + "Enchanted Crystal");
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
return item;
}
示例15: setLores
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemMaker setLores(String... lores) {
ItemMeta itemMeta = this.itemStack.getItemMeta();
List<String> loresList = new ArrayList<>();
for (String lore : lores) {
loresList.add(lore);
}
itemMeta.setLore(loresList);
this.itemStack.setItemMeta(itemMeta);
return this;
}