當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemMeta.getDisplayName方法代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:22,代碼來源:PlayerDataRPG.java

示例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);
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:21,代碼來源:ItemStacks.java

示例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();
        }
    });
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:29,代碼來源:MapRatingsMatchModule.java

示例4: ItemMetaMock

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemMetaMock(ItemMeta meta)
{
	if (meta.hasDisplayName())
	{
		displayName = meta.getDisplayName();
	}
}
 
開發者ID:seeseemelk,項目名稱:MockBukkit,代碼行數:8,代碼來源:ItemMetaMock.java

示例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);
}
 
開發者ID:GigaGamma,項目名稱:McLink,代碼行數:10,代碼來源:ToggleButton.java

示例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;
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:6,代碼來源:ItemWrapper.java

示例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;
				}
			}
		}
	}
}
 
開發者ID:Soldier233,項目名稱:SlimefunBugFixer,代碼行數:49,代碼來源:ListenersRes4.java


注:本文中的org.bukkit.inventory.meta.ItemMeta.getDisplayName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。