本文整理匯總了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;
}
}
}
}
}