当前位置: 首页>>代码示例>>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;未经允许,请勿转载。