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

com.sucy.skill.dynamic.trigger.HealTrigger 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.trigger;

import com.sucy.skill.api.Settings;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityRegainHealthEvent;

import java.util.Map;

public class HealTrigger implements Trigger {
    /**
     * {@inheritDoc}
     */
    @Override
    public String getKey() {
        return "HEAL";
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Class getEvent() {return EntityRegainHealthEvent.class;}

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean shouldTrigger(EntityRegainHealthEvent event, int level, Settings settings) {
        final double min = settings.getDouble("heal-min");
        final double max = settings.getDouble("heal-max");
        return event.getAmount() >= min && event.getAmount() <= max;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setValues(EntityRegainHealthEvent event, Map data) {
        data.put("api-heal", event.getAmount());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public LivingEntity getCaster(EntityRegainHealthEvent event) {
        return (LivingEntity) event.getEntity();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public LivingEntity getTarget(EntityRegainHealthEvent event, Settings settings) {
        return (LivingEntity) event.getEntity();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy