Java Code Examples for org.bukkit.util.NumberConversions#toFloat()

The following examples show how to use org.bukkit.util.NumberConversions#toFloat() . 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: Location.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Required method for deserialization
 *
 * @param args map to deserialize
 * @return deserialized location
 * @throws IllegalArgumentException if the world don't exists
 * @see ConfigurationSerializable
 */
public static Location deserialize(Map<String, Object> args) {
    World world = Bukkit.getWorld((String) args.get("world"));
    if (world == null) {
        throw new IllegalArgumentException("unknown world");
    }

    return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch")));
}
 
Example 2
Source File: CronusParser.java    From TabooLib with MIT License 5 votes vote down vote up
public static org.bukkit.Location toBukkitLocation(Object in) {
    String[] v = String.valueOf(in).split(",");
    return new org.bukkit.Location(
            v.length > 0 ? Bukkit.getWorld(v[0]) : Bukkit.getWorlds().iterator().next(),
            v.length > 1 ? NumberConversions.toDouble(v[1]) : 0,
            v.length > 2 ? NumberConversions.toDouble(v[2]) : 0,
            v.length > 3 ? NumberConversions.toDouble(v[3]) : 0,
            v.length > 4 ? NumberConversions.toFloat(v[4]) : 0,
            v.length > 5 ? NumberConversions.toFloat(v[5]) : 0);
}
 
Example 3
Source File: TLocaleBossBar.java    From TabooLib with MIT License 5 votes vote down vote up
public static TLocaleBossBar valueOf(Map<String, Object> map) {
    return new TLocaleBossBar(
            map.getOrDefault("text", "ยง4* Invalid Text*").toString(),
            getColor(String.valueOf(map.get("color"))),
            getStyle(String.valueOf(map.get("style"))),
            NumberConversions.toFloat(map.getOrDefault("progress", 1)),
            NumberConversions.toInt(map.getOrDefault("timeout", 20)),
            NumberConversions.toInt(map.getOrDefault("timeout-interval", 2)),
            isPlaceholderEnabled(map));
}
 
Example 4
Source File: MetadataValueAdapter.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public float asFloat() {
    return NumberConversions.toFloat(value());
}
 
Example 5
Source File: NBTBase.java    From TabooLib with MIT License 4 votes vote down vote up
public float asFloat() {
    return NumberConversions.toFloat(data);
}
 
Example 6
Source File: Numbers.java    From TabooLib with MIT License 4 votes vote down vote up
public static float toFloat(Object in) {
    return NumberConversions.toFloat(in);
}