当前位置: 首页>>代码示例>>Java>>正文


Java Player.getMetadata方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getMetadata方法的具体用法?Java Player.getMetadata怎么用?Java Player.getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.getMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLastLandChangedMeta

import org.bukkit.entity.Player; //导入方法依赖的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

示例2: onItemPickup

import org.bukkit.entity.Player; //导入方法依赖的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

示例3: get

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private boolean get(Player player, String key, boolean fallback) {
    final MetadataValue value = player.getMetadata(key, plugin);
    return value != null ? value.asBoolean() : fallback;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:PlayerStatesImpl.java

示例4: isVanished

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private boolean isVanished(Player player) {
    for (MetadataValue meta : player.getMetadata("vanished")) {
        if (meta.asBoolean()) return true;
    }
    return false;
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:7,代码来源:ListCmd.java


注:本文中的org.bukkit.entity.Player.getMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。