本文整理匯總了Java中org.bukkit.inventory.meta.ItemMeta.getLore方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemMeta.getLore方法的具體用法?Java ItemMeta.getLore怎麽用?Java ItemMeta.getLore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.ItemMeta
的用法示例。
在下文中一共展示了ItemMeta.getLore方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockPlace
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlockPlaced();
ItemStack stack = event.getItemInHand();
Player player = event.getPlayer();
if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) {
ItemMeta meta = stack.getItemMeta();
if (meta.hasLore() && meta.hasDisplayName()) {
CreatureSpawner spawner = (CreatureSpawner) block.getState();
List<String> lore = meta.getLore();
if (!lore.isEmpty()) {
String spawnerName = ChatColor.stripColor(lore.get(0).toUpperCase());
Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class, spawnerName);
if (entityTypeOptional.isPresent()) {
spawner.setSpawnedType(entityTypeOptional.get());
spawner.update(true, true);
player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner.");
}
}
}
}
}
示例2: open
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public void open(Player p){
Inventory inv = Bukkit.createInventory(null, 54, getInventoryName());
Set<String> list = config.getConfigurationSection("items").getKeys(false);
int slot = 0;
for(String name : list){
ItemStack is = ItemHelper.toItemStack(name);
ItemMeta im = is.getItemMeta();
List<String> lore = im.hasLore() ? im.getLore() : new ArrayList<>();
lore.add("§f");
lore.add("§7아이템 이름: " + name);
Util.setItem(im.getDisplayName(),is.getType(),is.getDurability(),is.getAmount(),lore,is.getEnchantments(),slot,inv);
slot++;
}
p.openInventory(inv);
}
示例3: getValidEnchantments
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private Map<CustomEnchantment, Integer> getValidEnchantments(ArrayList<ItemStack> items) {
Map<CustomEnchantment, Integer> validEnchantments = new HashMap<>();
for (ItemStack item : items) {
if (item == null) continue;
ItemMeta meta = item.getItemMeta();
if (meta == null) continue;
if (!meta.hasLore()) continue;
for (String lore : meta.getLore()) {
String name = EnchantUtils.parseName(lore);
int level = EnchantUtils.parseLevel(lore);
if (name == null) continue;
if (level == 0) continue;
if (Main.isEnchantmentRegistered(name)) {
CustomEnchantment enchant = Main.getEnchantment(name);
if (enchant.isStackable() && validEnchantments.containsKey(enchant)) {
level += validEnchantments.get(enchant);
}
validEnchantments.put(enchant, level);
}
}
}
return validEnchantments;
}
示例4: onBlockPlace
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event)
{
ItemStack stack = event.getItemInHand();
BlockState state = event.getBlock().getState();
if (((state instanceof Sign)) && (stack.hasItemMeta()))
{
ItemMeta meta = stack.getItemMeta();
if ((meta.hasDisplayName()) && (meta.getDisplayName().equals(EVENT_SIGN_ITEM_NAME)))
{
Sign sign = (Sign)state;
List<String> lore = meta.getLore();
int count = 0;
for (String loreLine : lore)
{
sign.setLine(count++, loreLine);
if (count == 4) {
break;
}
}
sign.update();
}
}
}
示例5: getBuyableSlotForLine
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@NotNull
public static ItemStack getBuyableSlotForLine(int line) {
ItemStack slot = buyableSlot.clone();
ItemMeta im = slot.getItemMeta();
List<String> lore = im.getLore();
FileLanguage lang = RPGInventory.getLanguage();
if (Config.getConfig().getBoolean("slots.money.enabled")) {
lore.add(lang.getMessage("buyable.money", StringUtils.doubleToString(Config.getConfig().getDouble("slots.money.cost.line" + line))));
}
if (Config.getConfig().getBoolean("slots.level.enabled")) {
lore.add(lang.getMessage("buyable.level", Config.getConfig().getInt("slots.level.required.line" + line)));
}
im.setLore(lore);
slot.setItemMeta(im);
return addId(slot);
}
示例6: attach
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static ItemStack attach(ItemStack it, String id) {
ItemStack i = it.clone();
ItemMeta m = i.getItemMeta();
List<String> lore = new ArrayList<String>();
lore.addAll(Arrays.asList(new String[] {ChatColor.RESET + "" + ChatColor.DARK_GRAY + id}));
if (m.getLore() != null && !m.getLore().isEmpty()) {
lore.add("");
lore.addAll(m.getLore());
}
m.setLore(lore);
i.setItemMeta(m);
return i;
}
示例7: syncInfoSlots
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void syncInfoSlots(PlayerWrapper playerWrapper) {
final Player player = (Player) playerWrapper.getPlayer();
for (Slot infoSlot : SlotManager.instance().getInfoSlots()) {
ItemStack cup = infoSlot.getCup();
ItemMeta meta = cup.getItemMeta();
List<String> lore = meta.getLore();
for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i);
lore.set(i, StringUtils.setPlaceholders(player, line));
}
meta.setLore(lore);
cup.setItemMeta(meta);
playerWrapper.getInventory().setItem(infoSlot.getSlotId(), cup);
}
player.updateInventory();
}
示例8: ShopIcon
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
ShopIcon(Hub hub, String categoryName, int storageId, int slot, int[] resetIds) throws Exception
{
this.hub = hub;
this.storageId = storageId;
this.slot = slot;
this.resetIds = resetIds;
hub.getGameManager().log(Level.INFO, "Fetching shop icon data for the id: " + storageId);
this.itemDescription = SamaGamesAPI.get().getShopsManager().getItemDescription(storageId);
this.icon = PersistanceUtils.makeStack(hub, this.itemDescription);
if (categoryName != null)
{
ItemMeta meta = this.icon.getItemMeta();
List<String> lore = (meta.getLore() != null) ? meta.getLore() : new ArrayList<>();
lore.add(0, ChatColor.DARK_GRAY + categoryName);
if (meta.getLore() != null)
lore.add(1, "");
meta.setLore(lore);
this.icon.setItemMeta(meta);
}
}
示例9: removeItemLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack removeItemLore(ItemStack item, Ability ability) {
ItemStack newItem = item.clone();
ItemMeta newMeta = newItem.getItemMeta();
List<String> newLore = newMeta.getLore();
newLore.remove(ChatColor.GRAY + "Ability: " + ChatColor.RED + ability.getName());
newLore.remove(ChatColor.GRAY + "Temporary");
newMeta.setLore(newLore);
newItem.setItemMeta(newMeta);
return newItem;
}
示例10: toItemStack
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private ItemStack toItemStack(VillagerTrade trade, Player player, Game game) {
ItemStack tradeStack = trade.getRewardItem().clone();
Method colorable = Utils.getColorableMethod(tradeStack.getType());
ItemMeta meta = tradeStack.getItemMeta();
ItemStack item1 = trade.getItem1();
ItemStack item2 = trade.getItem2();
if ((tradeStack.getType().equals(Material.STAINED_GLASS))
|| (tradeStack.getType().equals(Material.WOOL))
|| (tradeStack.getType().equals(Material.STAINED_CLAY))) {
tradeStack.setDurability((short) game.getPlayerTeam(player)
.getColor().getDyeColor().getData());
} else if (colorable != null) {
colorable.setAccessible(true);
try {
colorable.invoke(meta, new Object[] { game
.getPlayerTeam(player).getColor().getColor() });
} catch (Exception e) {
e.printStackTrace();
}
}
List<String> lores = meta.getLore();
if (lores == null) {
lores = new ArrayList<String>();
}
if (trade instanceof XPVillagerTrade) {
lores.add("��a" + ((XPVillagerTrade) trade).getXP() + " ����");
} else {
lores.add(ChatColor.WHITE + String.valueOf(item1.getAmount()) + " "
+ item1.getItemMeta().getDisplayName());
if (item2 != null) {
lores.add(ChatColor.WHITE + String.valueOf(item2.getAmount())
+ " " + item2.getItemMeta().getDisplayName());
}
}
meta.setLore(lores);
tradeStack.setItemMeta(meta);
return tradeStack;
}
示例11: addToItem
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack addToItem(ItemStack item, int enchantLevel)
{
Validate.notNull(item);
ItemMeta meta = item.getItemMeta();
if (meta == null) meta = Bukkit.getServer().getItemFactory().getItemMeta(item.getType());
List<String> metaLore = meta.getLore() == null ? new ArrayList<>() : meta.getLore();
// Make sure the enchantment doesn't already exist on the item
for (Map.Entry<CustomEnchantment, Integer> entry : getEnchantments(item).entrySet())
{
if (entry.getKey().getName().equals(getName()))
{
if (entry.getValue() < enchantLevel)
{
metaLore.remove(ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(entry.getValue()));
}
else
{
return item;
}
}
}
// Add the enchantment
metaLore.add(0, ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(enchantLevel));
meta.setLore(metaLore);
String name = EnchantUtils.getName(item);
if (name != null) meta.setDisplayName(name);
item.setItemMeta(meta);
return item;
}
示例12: withLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStackBuilder withLore(String name) {
if (itemStack.getType() == Material.AIR) return this;
final ItemMeta meta = itemStack.getItemMeta();
List<String> lore = meta.getLore();
if (lore == null) {
lore = new ArrayList<>();
}
lore.add(Colors.color(name));
meta.setLore(lore);
itemStack.setItemMeta(meta);
return this;
}
示例13: fromStack
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
/**
* Parses an {@link Crowbar} from a given {@link ItemStack}.
*
* @param stack
* the stack to parse from
* @return the {@link Crowbar} instance
*/
public static Optional<Crowbar> fromStack(ItemStack stack) {
if (stack == null || !stack.hasItemMeta()) {
return Optional.absent();
}
ItemMeta meta = stack.getItemMeta();
if (!meta.hasDisplayName() || !meta.hasLore() || !meta.getDisplayName().equals(CROWBAR_NAME)) {
return Optional.absent();
}
Crowbar crowbar = new Crowbar();
List<String> loreList = meta.getLore();
for (String lore : loreList) {
lore = ChatColor.stripColor(lore);
int length = lore.length();
for (int i = 0; i < length; i++) {
char character = lore.charAt(i);
if (Character.isDigit(character)) {
int amount = Integer.parseInt(String.valueOf(character));
if (lore.startsWith(END_FRAME_USE_TAG)) {
crowbar.setEndFrameUses(amount);
break;
} else if (lore.startsWith(SPAWNER_USE_TAG)) {
crowbar.setSpawnerUses(amount);
break;
}
}
}
}
return Optional.of(crowbar);
}
示例14: getReleaseCrateKey
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static ItemStack getReleaseCrateKey(){
ItemStack key = new ItemStack(Material.TRIPWIRE_HOOK);
ItemMeta keyMeta = key.getItemMeta();
keyMeta.setDisplayName(ChatColor.GOLD + "Release Crate Key");
List<String> lore = keyMeta.getLore();
lore.clear();
lore.add("Bring this to the release crate at spawn to open!");
keyMeta.setLore(lore);
key.setItemMeta(keyMeta);
return key;
}
示例15: updateMagazineLore
import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
/**
* Given a magazine object, updates the lore to reflect the NBT
*
* @param magazine the magazine to update
* @return the magazine, with updated lore.
*/
public ItemStack updateMagazineLore(ItemStack magazine) {
ItemMeta meta = magazine.getItemMeta();
List<String> lore = meta.getLore();
if (lore == null) {
lore = new ArrayList<String>();
} else {
lore.clear();
}
lore.add(this.tag);
if (this.exampleLore != null && !this.exampleLore.isEmpty()) {
lore.addAll(this.exampleLore);
}
Map<String, Object> magazineData = getMagazineData(magazine);
String ammo = magazineData.containsKey("ammo") ? (String) magazineData.get("ammo") : null;
Integer rounds = (Integer) magazineData.get("rounds");
if (ammo != null) { // locked / has a bullet
lore.add(ChatColor.GREEN + "Magazine of " + ChatColor.GRAY + ammo);
if (rounds <= 0) {
lore.add(ChatColor.RED + " EMPTY " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
} else if (rounds == 1) {
lore.add(ChatColor.GOLD + " 1 " + ChatColor.BLUE + "Round " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
} else {
lore.add(ChatColor.GREEN + String.format(" %d ", rounds) + ChatColor.BLUE + "Rounds " + ChatColor.DARK_AQUA + "(out of " + ChatColor.WHITE + this.allowsRounds.get(ammo) + ChatColor.DARK_AQUA + " max)");
}
} else {
lore.add(ChatColor.RED + "Magazine Empty");
lore.add(ChatColor.GREEN + "Accepts bullets: ");
for (String bull : this.allowedBullets) {
lore.add(ChatColor.GREEN + " - " + ChatColor.GRAY + bull);
}
}
meta.setLore(lore);
magazine.setItemMeta(meta);
return magazine;
}