@Override public boolean asBoolean() { return this.value.asBoolean(); }
public boolean isVanished(Player player) { List<MetadataValue> values = player.getMetadata("vanished"); for (MetadataValue value : values) { if (value.asBoolean()) { return true; } } return false; }
@Override public boolean isVanished(Entity entity) { if (entity == null) return false; for (MetadataValue meta : entity.getMetadata("vanished")) { return meta.asBoolean(); } return false; }
/** * Check to see if god mode is enabled for a player. * * @param player The player to check * @return Whether the player has godmode */ public boolean hasGodMode(Player player) { List<MetadataValue> values = player.getMetadata(METADATA_KEY); switch (values.size()) { case 0: return false; case 1: return values.get(0).asBoolean(); default: for (MetadataValue val : values) { if (val.asBoolean()) { return true; } } return false; } }
public static boolean isVanished(Player player) { if (player != null && player.hasMetadata("vanished") && !player.getMetadata("vanished").isEmpty()) { return player.getMetadata("vanished").get(0).asBoolean(); } return false; }
public MobHealthDisplayUpdaterTask(LivingEntity target) { if (target.isValid()) { this.target = target; this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString(); this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean(); } }
/** * Monitor EntityDeath events. * * @param event * The event to watch */ @EventHandler(priority = EventPriority.LOWEST) public void onEntityDeathLowest(EntityDeathEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; LivingEntity entity = event.getEntity(); if (Misc.isNPCEntity(entity)) { return; } if (entity.hasMetadata(mcMMO.customNameKey)) { entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString()); entity.removeMetadata(mcMMO.customNameKey, plugin); } if (entity.hasMetadata(mcMMO.customVisibleKey)) { entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean()); entity.removeMetadata(mcMMO.customVisibleKey, plugin); } if (entity.hasMetadata(mcMMO.entityMetadataKey)) { entity.removeMetadata(mcMMO.entityMetadataKey, plugin); } }