本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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);
}
}
示例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));
}
示例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;
}
示例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);
}
}
示例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;
}
示例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
}
示例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;
}
}