Java Code Examples for org.bukkit.metadata.MetadataValue#asBoolean()

The following examples show how to use org.bukkit.metadata.MetadataValue#asBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Game.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
public void onPlayerTeleport(PlayerTeleportEvent event, SpleefPlayer player) {
	Player bukkitPlayer = player.getBukkitPlayer();
	
	if (bukkitPlayer.hasMetadata(SpleefPlayer.ALLOW_NEXT_TELEPORT_KEY)) {
		List<MetadataValue> values = bukkitPlayer.getMetadata(SpleefPlayer.ALLOW_NEXT_TELEPORT_KEY);
		
		for (MetadataValue value : values) {
			if (value.getOwningPlugin() != heavySpleef.getPlugin()) {
				continue;
			}
			
			if (value.asBoolean()) {
				return;
			}
		}
	}
	
	event.setCancelled(true);
}
 
Example 2
Source File: FlagBowspleef.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
private void cancelBowSpleefEntityEvent(Entity entity, Cancellable cancellable) {
	boolean isBowspleefEntity = false;
	List<MetadataValue> metadatas = entity.getMetadata(BOWSPLEEF_METADATA_KEY);
	for (MetadataValue value : metadatas) {
		if (value.getOwningPlugin() != getHeavySpleef().getPlugin()) {
			continue;
		}
		
		isBowspleefEntity = value.asBoolean();
	}
	
	if (isBowspleefEntity) {
		entity.remove();
		cancellable.setCancelled(true);
	}
}
 
Example 3
Source File: BukkitPartyPlayerImpl.java    From Parties with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean isVanished() {
	Player player = Bukkit.getPlayer(this.getPlayerUUID());
	if (player != null) {
		for (MetadataValue meta : player.getMetadata("vanished")) {
			if (meta.asBoolean()) return true;
		}
	}
	return false;
}
 
Example 4
Source File: HookBukkitVanish.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isVanished(Player player) {
    if(player == null) return false;

    List<MetadataValue> metaList = player.getMetadata("vanished");
    for(MetadataValue meta : metaList) {
        boolean value = meta.asBoolean();
        if(value) return true;
    }

    return false;
}
 
Example 5
Source File: Checker.java    From Harbor with MIT License 4 votes vote down vote up
public static boolean isVanished(final Player player) {
    for (MetadataValue meta : player.getMetadata("vanished")) if (meta.asBoolean()) return true;
    return false;
}
 
Example 6
Source File: AntiVPN.java    From AntiVPN with MIT License 4 votes vote down vote up
private boolean isVanished(Player player) {
    for (MetadataValue meta : player.getMetadata("vanished")) {
        if (meta.asBoolean()) return true;
    }
    return false;
}
 
Example 7
Source File: PlayerStatesImpl.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private boolean get(Player player, String key, boolean fallback) {
    final MetadataValue value = player.getMetadata(key, plugin);
    return value != null ? value.asBoolean() : fallback;
}
 
Example 8
Source File: Meta.java    From NovaGuilds with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Checks if a block is protected
 *
 * @param block block
 * @return boolean
 */
public static boolean isProtected(Block block) {
	MetadataValue metadataValue = getMetadata(block, "protected");
	return metadataValue != null && metadataValue.asBoolean();
}