public ItemStack getItem() {
List<String> lore = new ArrayList<String>();
for (int i=0; i<this.lore.length; i++) {
lore.add(ChatColor.translateAlternateColorCodes('&', this.lore[i]));
}
ItemStack item = new ItemStack(this.type, this.amount, this.data);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
meta.spigot().setUnbreakable(this.unbreakable);
item.setItemMeta(meta);
return item;
}
java类org.bukkit.inventory.meta.ItemMeta的实例源码
ItemBuilder.java 文件源码
项目:ZorahPractice
阅读 27
收藏 0
点赞 0
评论 0
EmpireWandModule.java 文件源码
项目:KingdomFactions
阅读 24
收藏 0
点赞 0
评论 0
public ItemStack getEmpireWand() {
ItemStack empirewand = new ItemStack(Material.BLAZE_ROD, 1);
ItemMeta meta = empirewand.getItemMeta();
meta.setDisplayName(ChatColor.RED + "Empire Wand");
ArrayList<String> lore = new ArrayList<String>();
try {
lore.add(ChatColor.translateAlternateColorCodes('&', new Randomizer<String>(KingdomFactionsPlugin.getInstance()
.getDataManager().getArrayData("Empirewand.lores").getValue()).result()));
} catch (DataException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
meta.setLore(lore);
meta.addEnchant(Enchantment.LURE, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
empirewand.setItemMeta(meta);
return empirewand;
}
SkullItemBuilder.java 文件源码
项目:AlphaLibary
阅读 24
收藏 0
点赞 0
评论 0
public static ItemStack getCustomSkull(String url) {
GameProfile profile = SkinChangeUtil.changeSkin(url);
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta headMeta = head.getItemMeta();
Class<?> headMetaClass = headMeta.getClass();
try {
Field f = headMetaClass.getDeclaredField("profile");
f.setAccessible(true);
f.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
BanRequest.java 文件源码
项目:EpicBanRequests
阅读 20
收藏 0
点赞 0
评论 0
public ItemStack getItem() {
ItemStack is = new ItemStack(Material.PAPER);
ItemMeta im = is.getItemMeta();
/**
* Item:
*
* Name = Request #x
* Lore 1: Requested by: _name_
* Lore : Ban:
* Lore 2: Reason: reason
* Lore 3: Time: time
*/
im.setDisplayName(Messager.color("&eRequest #" + id));
im.setLore(Arrays.asList(Messager.color("&eRequested by: &7" + Bukkit.getOfflinePlayer(UUID.fromString(openerUUID)).getName()),
Messager.color("&eBan: &7" + Bukkit.getOfflinePlayer(UUID.fromString(playerToBanUUID)).getName()),
Messager.color("&eReason: &7" + banReason),
Messager.color("&eRequested at: &7" + timeOpenedFormatted)));
is.setItemMeta(im);
return is;
}
TradeOfferCommand.java 文件源码
项目:FactionsXL
阅读 25
收藏 0
点赞 0
评论 0
private Inventory choosePartner(Faction creator) {
int size = (int) (9 * Math.ceil(((double) factions.getActive().size() / 9)));
Inventory gui = Bukkit.createInventory(null, size, FMessage.TRADE_OFFER_CHOOSE_PARTNER.getMessage());
int i = 0;
for (Faction faction : factions.getActive()) {
ItemStack icon = faction.getBannerStack();
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName(creator.getRelation(faction).getColor() + faction.getName());
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
icon.setItemMeta(meta);
gui.setItem(i, icon);
factionBySlot.put(i, faction);
i++;
}
return gui;
}
ItemStackBuilder.java 文件源码
项目:BlockBall
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
DefuseListener.java 文件源码
项目:ProjectAres
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void giveKit(final ObserverKitApplyEvent event) {
final MatchPlayer player = mm.getPlayer(event.getPlayer());
if(player == null) return;
if(!player.isObservingType()) return;
if(!player.getBukkit().hasPermission("pgm.defuse")) return;
ItemStack shears = new ItemStack(DEFUSE_ITEM);
// TODO: Update information if locale changes
ItemMeta meta = shears.getItemMeta();
meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(PGMTranslations.t("defuse.displayName", player));
meta.setLore(Lists.newArrayList(ChatColor.GRAY + PGMTranslations.t("defuse.tooltip", player)));
shears.setItemMeta(meta);
event.getPlayer().getInventory().setItem(DEFUSE_SLOT, shears);
}
LongRangeWeapon.java 文件源码
项目:SuperiorCraft
阅读 31
收藏 0
点赞 0
评论 0
public LongRangeWeapon(Material wep, String name, Material ammo, String desc, String type, double damage, int cooltime, boolean isCrit, int knockback, boolean silent, int shots, String proj) {
this.wep = wep;
this.name = name;
this.ammo = ammo;
this.desc = desc;
this.type = type;
this.damage = damage;
this.cooltime = cooltime;
this.isCrit = isCrit;
this.knockback = knockback;
this.silent = silent;
this.shots = shots;
this.proj = proj;
ItemStack item = new ItemStack(wep);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.BOLD + name);
ArrayList<String> lore = new ArrayList<String>();
lore.add(ChatColor.BOLD + desc);
lore.add(ChatColor.WHITE + type);
meta.setLore(lore);
item.setItemMeta(meta);
addWep(item);
}
BagBase.java 文件源码
项目:Bags2
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void onInteract(PlayerInteractEvent e, EquipmentSlot es)
{
ItemStack stack = es.equals(EquipmentSlot.HAND) ? e.getPlayer().getInventory().getItemInMainHand() : e.getPlayer().getInventory().getItemInOffHand();
if(stack.hasItemMeta() ? !stack.getItemMeta().getDisplayName().equals(Translation.get(name)) : false)
{
if(stack.getItemMeta().getDisplayName().startsWith(ChatColor.RESET.toString()))
{
ItemMeta im = stack.getItemMeta();
if(!im.getDisplayName().startsWith(ChatColor.ITALIC.toString()))
im.setDisplayName(ChatColor.RESET + Translation.get(name));
stack.setItemMeta(im);
if(es.equals(EquipmentSlot.HAND))
e.getPlayer().getInventory().setItemInMainHand(stack);
else
e.getPlayer().getInventory().setItemInOffHand(stack);
}
}
super.onInteract(e, es);
}
PickTest.java 文件源码
项目:prisonPicks
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testIsPick() {
//make a mock Xpick
ItemMeta i = mock(ItemMeta.class);
doReturn(true).when(i).hasLore();
doReturn(Material.DIAMOND_PICKAXE).when(tool).getType();
doReturn(true).when(tool).hasItemMeta();
doReturn(i).when(tool).getItemMeta();
//this should work
assertTrue(Pick.isPick(tool));
//no lore
doReturn(false).when(i).hasLore();
assertFalse(Pick.isPick(tool));
//no metadata
doReturn(false).when(tool).hasItemMeta();
assertFalse(Pick.isPick(tool));
}
CrowbarListener.java 文件源码
项目:HCFCore
阅读 22
收藏 0
点赞 0
评论 0
@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.");
}
}
}
}
}
PlayerDataRPG.java 文件源码
项目:ZentrelaRPG
阅读 24
收藏 0
点赞 0
评论 0
private void addSet(ItemStack item) {
if (item == null)
return;
ItemMeta im = item.getItemMeta();
if (im == null)
return;
if (!im.hasDisplayName())
return;
if (im.getDisplayName().startsWith("*"))
return;
String name = im.getDisplayName();
for (String s : ItemBalance.SET_PREFIXES) {
if (name.contains(s)) {
if (armorSetCounter.containsKey(s))
armorSetCounter.put(s, armorSetCounter.get(s) + 1);
else
armorSetCounter.put(s, 1);
break;
}
}
}
Utils.java 文件源码
项目:Arcadia-Spigot
阅读 20
收藏 0
点赞 0
评论 0
public static void resetPlayer(Player player) {
player.setLevel(0);
player.setExp(0);
player.setFoodLevel(20);
player.setHealth(20);
player.setHealthScale(20);
player.setExhaustion(0);
player.getInventory().clear();
ItemStack blankItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) 15);
ItemMeta blankMeta = blankItem.getItemMeta();
blankMeta.setDisplayName("" + ChatColor.RED);
blankItem.setItemMeta(blankMeta);
for(int i=9; i<=35; i++) {
player.getInventory().setItem(i, blankItem);
}
player.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
player.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
player.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
player.getInventory().setBoots(new ItemStack(Material.AIR, 1));
for(PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
player.setFireTicks(0);
}
MenuManager.java 文件源码
项目:ZentrelaCore
阅读 38
收藏 0
点赞 0
评论 0
private static String serializeForMenu(ItemStack item) {
StringBuilder sb = new StringBuilder();
sb.append(item.getType());
sb.append('$');
sb.append(item.getAmount());
if (item.hasItemMeta()) {
ItemMeta im = item.getItemMeta();
if (im.hasDisplayName()) {
sb.append('#');
sb.append(im.getDisplayName());
}
if (im.hasLore()) {
sb.append('#');
sb.append(im.getLore().toString());
}
if (im.hasEnchants()) {
sb.append('#');
sb.append(im.getEnchants().toString());
}
}
return sb.toString();
}
KitsCommand.java 文件源码
项目:HCFCore
阅读 32
收藏 0
点赞 0
评论 0
private ItemStack titaniumKitGlass(Player player) {
ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 14);
ItemMeta meta = stack.getItemMeta();
addGlow(stack);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4Titanium &7Kit"));
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&7This is a kit contains:"));
lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Diamond kit!"));
lore.add("");
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase the Titanium Rank 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("TitaniumKit")) {
lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("TitaniumKit"), 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;
}
CustomEnchantment.java 文件源码
项目:Scorch
阅读 25
收藏 0
点赞 0
评论 0
public ItemStack removeFromItem(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
if (meta == null) return item;
if (!meta.hasLore()) return item;
List<String> metaLore = 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()))
{
metaLore.remove(ChatColor.GRAY + getName() + " " + RomanNumerals.numeralOf(entry.getValue()));
}
}
return item;
}
GUIManager.java 文件源码
项目:EpicBanRequests
阅读 19
收藏 0
点赞 0
评论 0
public static Inventory archived(Player player) {
Inventory i = Bukkit.createInventory(null, 54, Messager.color("&7Archived Requests"));
ItemStack back = new ItemStack(Material.ARROW);
ItemMeta im = back.getItemMeta();
im.setDisplayName(Messager.color("&cBack"));
back.setItemMeta(im);
i.setItem(45, back);
int tillFull = 0;
for (int x = Main.getInstance().getConfig().getInt("current_id"); x <= 0; x--) {
if (tillFull >= 53) {
Messager.msgPlayer("&cAll of the archived requests could not fit in the GUI. Showing the newest first.", player);
break;
}
BanRequest br = new BanRequest(x);
if (br.closed) {
i.addItem(br.getArchivedItem());
tillFull++;
}
}
return i;
}
CraftExtension.java 文件源码
项目:RPGInventory
阅读 20
收藏 0
点赞 0
评论 0
CraftExtension(String name, ConfigurationSection config) {
this.name = name;
this.capItem = CraftManager.getCapItem().clone();
ItemMeta meta = capItem.getItemMeta();
meta.setDisplayName(StringUtils.coloredLine(config.getString("name")));
if (config.contains("lore")) {
meta.setLore(StringUtils.coloredLines(config.getStringList("lore")));
}
this.capItem.setItemMeta(meta);
this.slots = config.getIntegerList("slots");
if (config.contains("includes")) {
this.includes = new ArrayList<>();
for (String childName : config.getStringList("includes")) {
CraftExtension child = CraftManager.getByName(childName);
if (child != null) {
includes.add(child);
}
}
} else {
this.includes = null;
}
}
FireworkEffectsMeta.java 文件源码
项目:SaveableSerializing
阅读 23
收藏 0
点赞 0
评论 0
@Override
public SubMeta setFrom(ItemMeta meta) {
if(meta instanceof FireworkEffectMeta){
FireworkEffectMeta fire = (FireworkEffectMeta) meta;
me = new FireworkEffects(fire.getEffect());
}
return this;
}
AbilityManager.java 文件源码
项目:AsgardAscension
阅读 24
收藏 0
点赞 0
评论 0
public void applyAbility(Player player, ItemStack item, Ability ability, boolean temporary) {
// Adding lore
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.hasLore() ?
meta.getLore() : new ArrayList<>();
lore.add(ChatColor.GRAY + "Ability: " + ChatColor.RED + ability.getName());
if(temporary)
lore.add(ChatColor.GRAY + "Temporary");
meta.setLore(lore);
item.setItemMeta(meta);
player.getInventory().setItemInMainHand(item);
if(!temporary)
return;
// Adding timer for temporary abilities
new BukkitRunnable() {
@Override
public void run() {
if(!isActive(player, item)) {
this.cancel();
}
updateTemporaryItem(player, item, ability);
player.sendMessage(Lang.HEADERS_TOKENS.toString()
+ Lang.TOKENS_SHOP_EXPIRED.toString()
.replaceAll("%s", ability.getName()));
}
}.runTaskLater(plugin, 100 * 60 * 20);
}
XPItemShop.java 文件源码
项目:BedwarsXP
阅读 26
收藏 0
点赞 0
评论 0
private void addCategoriesToInventory(Inventory inventory, Player player) {
for (MerchantCategory category : this.categories) {
if (category.getMaterial() == null) {
Main.getInstance()
.getServer()
.getConsoleSender()
.sendMessage(
ChatWriter
.pluginMessage(ChatColor.RED
+ "Careful: Not supported material in shop category '"
+ category.getName() + "'"));
} else if ((player == null)
|| (player.hasPermission(category.getPermission()))) {
ItemStack is = new ItemStack(category.getMaterial(), 1);
ItemMeta im = is.getItemMeta();
if ((this.currentCategory != null)
&& (this.currentCategory.equals(category))) {
im.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
}
im.setDisplayName(category.getName());
im.setLore(category.getLores());
is.setItemMeta(im);
inventory.addItem(new ItemStack[] { is });
}
}
}
ItemStackBuilder.java 文件源码
项目:MinecraftMarket-Plugin
阅读 23
收藏 0
点赞 0
评论 0
public List<String> getLore() {
if (itemStack.getType() == Material.AIR) return new ArrayList<>();
final ItemMeta meta = itemStack.getItemMeta();
List<String> lore = meta.getLore();
if (lore == null) {
lore = new ArrayList<>();
}
return lore;
}
BottledExpListener.java 文件源码
项目:HCFCore
阅读 29
收藏 0
点赞 0
评论 0
/**
* Checks if an {@link ItemStack} is bottled exp.
*
* @param stack
* the {@link ItemStack} to check
* @return true if is bottled exp
*/
private boolean isBottledExperience(ItemStack stack) {
if (stack == null || !stack.hasItemMeta()) {
return false;
}
ItemMeta meta = stack.getItemMeta();
return meta.hasDisplayName() && meta.getDisplayName().equals(BOTTLED_EXP_DISPLAY_NAME);
}
DeathSignListener.java 文件源码
项目:HCFCore
阅读 26
收藏 0
点赞 0
评论 0
/**
* Generates a death-sign for a player and killer.
*
* @param playerName
* the name of the player killed
* @param killerName
* the name of the killer of player
* @return the death sign featuring the victim and murderer
*/
public static ItemStack getDeathSign(String playerName, String killerName) {
ItemStack stack = new ItemStack(Material.SIGN, 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(DEATH_SIGN_ITEM_NAME);
meta.setLore(Lists.newArrayList(ChatColor.RED + playerName, ChatColor.DARK_RED + "slain by", ChatColor.GREEN + killerName,
DateTimeFormats.DAY_MTH_HR_MIN_SECS.format(System.currentTimeMillis())));
stack.setItemMeta(meta);
return stack;
}
PotionMeta.java 文件源码
项目:SaveableSerializing
阅读 31
收藏 0
点赞 0
评论 0
@Override
public SubMeta setFrom(ItemMeta meta) {
if(meta instanceof org.bukkit.inventory.meta.PotionMeta) {
org.bukkit.inventory.meta.PotionMeta metar = (org.bukkit.inventory.meta.PotionMeta) meta;
for(PotionEffect ef : metar.getCustomEffects())
data.add(new PotionEffects(ef));
}
return this;
}
Items.java 文件源码
项目:RealSurvival
阅读 24
收藏 0
点赞 0
评论 0
/**
* l.add("��2���������Լ��õ����в���ҩ");
l.add("��eҲ������Ҫע�ⰴʱ��ҩ.");
* @return ҩ
*/
public static ItemStack getMedicine01(){
ItemStack sw=new ItemStack(Material.QUARTZ);
ItemMeta im = sw.getItemMeta();
im.setDisplayName("��a��lҩ");
List<String> l=new LinkedList<String>();
l.add("��2���������Լ��õ����в���ҩ");
l.add("��2�������������...");
l.add("��eҲ������Ҫע�ⰴʱ��ҩ.");
im.setLore(l);
sw.setItemMeta(im);
return sw;
}
FireworkEffectsMeta.java 文件源码
项目:SaveableSerializing
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void setTo(ItemMeta meta) {
if(meta instanceof FireworkEffectMeta){
FireworkEffectMeta fire = (FireworkEffectMeta) meta;
FireworkEffect ef = (FireworkEffect) me.getOriginal();
if(ef != null)
fire.setEffect(ef);
}
}
Util.java 文件源码
项目:BurkeyShop
阅读 19
收藏 0
点赞 0
评论 0
public static final ItemStack loreItemStack(ItemStack stack, List<String> lore) {
if(stack != null) {
ItemMeta meta = stack.getItemMeta();
for(int i = 0; i < lore.size(); i ++) { lore.set(i, color(lore.get(i))); }
meta.setLore(lore);
stack.setItemMeta(meta);
}
return stack;
}
Lore.java 文件源码
项目:HNRPG
阅读 23
收藏 0
点赞 0
评论 0
public void addLore(int ID, int DATA, int STACK, List<String> Lore, CommandSender sender) {
try {
Integer.parseInt(String.valueOf(tempStr));
ItemStack itemStack = new MaterialData(ID, (byte) DATA).toItemStack(STACK);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(Lore);
} catch (NumberFormatException e) {
sender.sendMessage("§c[ §4§l! §c] §3§l줄 수§7를 입력해주세요.");
return;
}
}
Icon.java 文件源码
项目:VanillaPlus
阅读 30
收藏 0
点赞 0
评论 0
public ItemStack getItemstack(VPPlayer player, Localizer loc){
ItemStack result = item;
ItemMeta itemMeta = item.getItemMeta();
if(name != null)
itemMeta.setDisplayName(getName(player, loc));
if(hasLore())
itemMeta.setLore(getLores(player, loc));
result.setItemMeta(itemMeta);
if(skullSelf){
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwner(player.getName());
result.setItemMeta(meta);
}
return result;
}