All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sucy.skill.dynamic.condition.WeatherCondition Maven / Gradle / Ivy

Go to download

A Minecraft Bukkit plugin aiming to provide an easy code API and skill editor for all server owners to create unique and fully custom classes and skills.

There is a newer version: 1.3.1-R1
Show newest version
package com.sucy.skill.dynamic.condition;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.LivingEntity;

/**
 * ProSkillAPI © 2023
 * com.sucy.skill.dynamic.condition.Weather
 */
public class WeatherCondition extends ConditionComponent {
    private String TYPE = "type";

    @Override
    boolean test(final LivingEntity caster, final int level, final LivingEntity target) {
        final String   type        = settings.getString(TYPE).toLowerCase();
        final World    world       = target.getWorld();
        final Location loc         = target.getLocation();
        final double   temperature = loc.getBlock().getTemperature();

        switch (type) {
            case "thunder":
                return world.isThundering() && temperature <= 1;
            case "rain":
                return world.hasStorm() && temperature > 0.15 && temperature <= 1;
            case "snow":
                return world.hasStorm() && temperature <= 0.15;
            default:
                return !world.hasStorm() || temperature > 1;
        }
    }

    @Override
    public String getKey() {
        return "weather";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy