本文整理汇总了Java中org.bukkit.inventory.meta.ItemMeta.getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:Java ItemMeta.getDisplayName方法的具体用法?Java ItemMeta.getDisplayName怎么用?Java ItemMeta.getDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.ItemMeta
的用法示例。
在下文中一共展示了ItemMeta.getDisplayName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSet
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
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;
}
}
}
示例2: replaceString
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public static void replaceString(ItemMeta meta, String target, String replacement) {
if (meta == null)
return;
String display = meta.getDisplayName();
if (display != null) {
display = display.replace(target, replacement);
}
List<String> lore = meta.getLore();
StringArrayList newLore = new StringArrayList();
if (lore != null) {
for (String element : lore) {
newLore.add(element.replace(target, replacement));
}
}
meta.setDisplayName(display);
meta.setLore(newLore);
}
示例3: onButtonClick
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@EventHandler
public void onButtonClick(final InventoryClickEvent event) {
ItemStack stack = event.getCurrentItem();
final MatchPlayer player = this.getMatch().getPlayer(event.getWhoClicked());
if(stack == null || player == null) return;
if(stack.getType() != Material.WOOL && stack.getType() != Material.CARPET) return;
ItemMeta meta = stack.getItemMeta();
if(!meta.hasDisplayName()) return;
String name = meta.getDisplayName();
if(!name.startsWith(BUTTON_PREFIX)) return;
event.setCancelled(true);
final int score = stack.getAmount();
if(!isScoreValid(score)) return;
this.getMatch().getScheduler(MatchScope.LOADED).createTask(() -> {
Integer oldScore = playerRatings.get(player);
if(oldScore == null || oldScore != score) {
player.playSound(Sound.UI_BUTTON_CLICK, 1, 2);
rate(player, score);
}
else {
player.getBukkit().closeInventory();
}
});
}
示例4: ItemMetaMock
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public ItemMetaMock(ItemMeta meta)
{
if (meta.hasDisplayName())
{
displayName = meta.getDisplayName();
}
}
示例5: onLoad
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@Override
public void onLoad(Gui gui, RawItemPosition item) {
item.getItem().setDurability(getDataFromBoolean(this.enabled).getData());
ItemMeta m = item.getItem().getItemMeta();
this.oname = m.getDisplayName();
m.setDisplayName(this.oname.replace("$nstate", enabled ? "Disable" : "Enable"));
item.getItem().setItemMeta(m);
}
示例6: getDisplayName
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
public String getDisplayName(String def) {
ItemMeta meta = getHandle().getItemMeta();
String displayName = meta.getDisplayName();
return displayName != null ? displayName : def;
}
示例7: onBlockBreak
import org.bukkit.inventory.meta.ItemMeta; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent evt) {
Player player = evt.getPlayer();
if (player == null) {
return;
}
ItemStack itemStack = player.getItemInHand();
if (itemStack.getType() != Material.DIAMOND_PICKAXE) {
return;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) {
return;
}
String displayName = itemMeta.getDisplayName();
if (displayName == null) {
return;
}
if (!displayName.contains(ITEM_NAME)) {
return;
}
Block block = evt.getBlock();
if (block == null) {
return;
}
Location location = block.getLocation();
String playerName = player.getName();
Location[][] arrayOfLocation;
int j = (arrayOfLocation = LocationUtil.getExplosivePickaxeBreakLocations(location)).length;
for (int i = 0; i < j; i++) {
Location[] locations = arrayOfLocation[i];
Location[] arrayOfLocation1;
int m = (arrayOfLocation1 = locations).length;
for (int k = 0; k < m; k++) {
Location FOR_location = arrayOfLocation1[k];
ClaimedResidence claimedResidence = RESIDENCE_MAMAGER.getByLoc(FOR_location);
if (claimedResidence != null) {
ResidencePermissions perms = claimedResidence.getPermissions();
boolean hasdestroy = perms.playerHas(playerName, Flags.destroy, true);
if ((!hasdestroy) && (!player.hasPermission("residence.bypass.destroy"))) {
this.RESIDENCE.msg(player, lm.Flag_Deny, new Object[] { Flags.destroy });
evt.setCancelled(true);
return;
}
}
}
}
}