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


Java MetadataValue類代碼示例

本文整理匯總了Java中org.bukkit.metadata.MetadataValue的典型用法代碼示例。如果您正苦於以下問題:Java MetadataValue類的具體用法?Java MetadataValue怎麽用?Java MetadataValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MetadataValue類屬於org.bukkit.metadata包,在下文中一共展示了MetadataValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: FromPlayer

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
static PlayerData FromPlayer(Player player)
{
    List<MetadataValue> data = player.getMetadata(METADATA_TAG);
    if(data == null || data.isEmpty())
    {
        return new PlayerData(player);
    }
    else
    {
        try
        {
            PlayerData playerData = (PlayerData)(data.get(0).value());
            return playerData;
        }
        catch(Exception e)
        {
            return new PlayerData(player);
        }
    }
}
 
開發者ID:BigScary,項目名稱:PhantomAdmin,代碼行數:21,代碼來源:PlayerData.java

示例2: getMapWrapper

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * @return the {@link MapWrapper} of the clicked frame
 */
public MapWrapper getMapWrapper() {
	if (this.mapWrapper != null) { return this.mapWrapper; }
	ItemFrame itemFrame = getItemFrame();
	if (itemFrame != null) {
		if (itemFrame.hasMetadata("MAP_WRAPPER_REF")) {
			List<MetadataValue> metadataValues = itemFrame.getMetadata("MAP_WRAPPER_REF");
			for (MetadataValue value : metadataValues) {
				MapWrapper wrapper = (MapWrapper) value.value();
				if (wrapper != null) {
					return this.mapWrapper = wrapper;
				}
			}
		}
	}
	return null;
}
 
開發者ID:InventivetalentDev,項目名稱:MapManager,代碼行數:20,代碼來源:MapInteractEvent.java

示例3: change

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (object.getSingle(e) instanceof Metadatable) {
		Metadatable metadata = (Metadatable)object.getSingle(e);
		if (mode == ChangeMode.SET) {
			if (metadata.hasMetadata(string.getSingle(e))) {
				metadata.removeMetadata(string.getSingle(e), Skellett.plugin);
			}
			metadata.setMetadata(string.getSingle(e), (MetadataValue)new FixedMetadataValue(Skellett.plugin, (Object)(delta[0])));
		} else if (mode == ChangeMode.RESET || mode == ChangeMode.DELETE) {
			if (metadata.hasMetadata(string.getSingle(e))) {
				metadata.removeMetadata(string.getSingle(e), Skellett.plugin);
			}
		}
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:ExprMetadata.java

示例4: getBooleanMetadata

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * 真偽値のメタデータを取得する
 * @param key キー
 * @return 値
 * @see org.bitbucket.ucchy.undine.sender.MailSender#getBooleanMetadata(java.lang.String)
 */
@Override
public boolean getBooleanMetadata(String key) {
    if ( offline == null ) {
        offline = getOfflinePlayer();
    }
    if ( !offline.isOnline() ) {
        return false;
    }
    List<MetadataValue> values = offline.getPlayer().getMetadata(key);
    if ( values.size() == 0 ) {
        return false;
    }
    return values.get(0).asBoolean();

}
 
開發者ID:ucchyocean,項目名稱:UndineMailer,代碼行數:22,代碼來源:MailSenderPlayer.java

示例5: getArmorStand

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
private ArmorStand getArmorStand(Block b) {
    UUID uuid = null;
    for (MetadataValue value : b.getMetadata("armorStand")) {
        if (value.getOwningPlugin() == plugin) {
            uuid = (UUID) value.value();
        }
    }
    b.removeMetadata("armorStand", plugin);
    if (uuid != null) {
        for(org.bukkit.entity.Entity e : b.getWorld().getEntities()) {
            if(e instanceof ArmorStand && e.getUniqueId().equals(uuid)) {
                return (ArmorStand) e;
            }
        }
    }
    return null;
}
 
開發者ID:St3venAU,項目名稱:ArmorStandTools,代碼行數:18,代碼來源:MainListener.java

示例6: getMetadata

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * Retrieves the metadata for a {@link Block}, ensuring the block being asked for actually belongs to this BlockMetadataStore's
 * owning world.
 * @see MetadataStoreBase#getMetadata(Object, String)
 */
@Override
public List<MetadataValue> getMetadata(Block block, String metadataKey) {
    if(block.getWorld() == owningWorld) {
        return super.getMetadata(block, metadataKey);
    } else {
        throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:14,代碼來源:BlockMetadataStore.java

示例7: setMetadata

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * Sets or overwrites a metadata value on a {@link Block} from a given {@link Plugin}, ensuring the target block belongs
 * to this BlockMetadataStore's owning world.
 * @see MetadataStoreBase#setMetadata(Object, String, org.bukkit.metadata.MetadataValue)
 */
@Override
public void setMetadata(Block block, String metadataKey, MetadataValue newMetadataValue) {
    if(block.getWorld() == owningWorld) {
        super.setMetadata(block, metadataKey, newMetadataValue);
    } else {
        throw new IllegalArgumentException("Block does not belong to world " + owningWorld.getName());
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:14,代碼來源:BlockMetadataStore.java

示例8: getMetadata

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
public static Object getMetadata(JavaPlugin plugin, Metadatable object, String key)
{
    List<MetadataValue> values = object.getMetadata(key);
    for (MetadataValue value : values)
    {
        if (value.getOwningPlugin().equals(plugin))
        {
            return value.value();
        }
    }

    return null;
}
 
開發者ID:SamaGames,項目名稱:AntiCheat,代碼行數:14,代碼來源:Metadatas.java

示例9: onQuit

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onQuit(PlayerQuitEvent event) {
    final MetadataValue future = event.getPlayer().getMetadata(METADATA_KEY, plugin);
    if(future != null) {
        ((SettableFuture) future.value()).set(null);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:PlayerServerChanger.java

示例10: setMetadata

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * Set a metadata value.
 * @param metadata - The object to set the metadata of.
 * @param key - The key to index the metadata by.
 * @param o - The object value to set.
 */
public static void setMetadata(Metadatable metadata, String key, Object o) {
    if (o instanceof MetadataValue)
        o = ((MetadataValue) o).value();
    if (o instanceof Enum<?>)
        o = ((Enum<?>) o).name();
    metadata.setMetadata(key, new FixedMetadataValue(Core.getInstance(), o));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:14,代碼來源:MetadataManager.java

示例11: getLastLandChangedMeta

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
private long getLastLandChangedMeta(Player player) {
    List<MetadataValue> value = player.getMetadata(LAND_CHANGED_META_KEY);
    long millis = System.currentTimeMillis();
    long remaining = value == null || value.isEmpty() ? 0L : value.get(0).asLong() - millis;
    if (remaining <= 0L) { // update the metadata.
        player.setMetadata(LAND_CHANGED_META_KEY, new FixedMetadataValue(plugin, millis + LAND_CHANGE_MSG_THRESHOLD));
    }

    return remaining;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:11,代碼來源:FactionListener.java

示例12: onItemPickup

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onItemPickup(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();
    long remaining = getRemaining(player);
    if (remaining > 0L) {
        UUID itemUUID = event.getItem().getUniqueId();
        Long delay = itemUUIDPickupDelays.get(itemUUID);
        if (delay == null)
            return;

        // The item has been spawned for over the required pickup time for
        // PVP Protected players, let them pick it up.
        long millis = System.currentTimeMillis();
        if ((delay - millis) > 0L) {
            event.setCancelled(true);

            // Don't let the pickup event spam the player.
            List<MetadataValue> value = player.getMetadata(ITEM_PICKUP_MESSAGE_META_KEY);
            if (value != null && !value.isEmpty() && value.get(0).asLong() - millis <= 0L) {
                player.setMetadata(ITEM_PICKUP_MESSAGE_META_KEY, new FixedMetadataValue(plugin, millis + ITEM_PICKUP_MESSAGE_DELAY));
                player.sendMessage(ChatColor.RED + "You cannot pick this item up for another " + ChatColor.BOLD + DurationFormatUtils.formatDurationWords(remaining, true, true) + ChatColor.RED
                        + " as your " + getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED
                        + " remaining]");
            }
        } else
            itemUUIDPickupDelays.remove(itemUUID);
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:29,代碼來源:InvincibilityTimer.java

示例13: getMetadataValue

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
private static String getMetadataValue(List<MetadataValue> values) {
    String text = null;
    for (MetadataValue v : values) {
        if (v.getOwningPlugin().getName().equalsIgnoreCase(Main.getInstance().getName())) {
            text = (String) v.value();
            break;
        }
    }
    return text;
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:11,代碼來源:Skill.java

示例14: get

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
/**
 * キャストが要らない取得の例示
 * @param value 取得する値
 */
@SuppressWarnings("unused")
private void get(MetadataValue value) {
	value.asBoolean(); // boolean
	value.asByte(); // byte
	value.asDouble(); // double
	value.asFloat(); // float
	value.asInt(); // int
	value.asLong(); // long
	value.asShort(); // short
	value.asString(); // String
}
 
開發者ID:HimaJyun,項目名稱:BukkitPluginDevelopment,代碼行數:16,代碼來源:Main.java

示例15: FromPlayer

import org.bukkit.metadata.MetadataValue; //導入依賴的package包/類
static PlayerData FromPlayer(Player player)
{
    List<MetadataValue> data = player.getMetadata(METADATA_TAG);
    if(data == null || data.isEmpty())
    {
        return new PlayerData(player);
    }
    else
    {
        PlayerData playerData = (PlayerData)(data.get(0).value());
        return playerData;
    }
}
 
開發者ID:BigScary,項目名稱:AutomaticInventory,代碼行數:14,代碼來源:PlayerData.java


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