studio.magemonkey.fabled.dynamic.trigger.PhysicalTrigger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabled Show documentation
Show all versions of fabled Show documentation
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.
package studio.magemonkey.fabled.dynamic.trigger;
import studio.magemonkey.fabled.api.Settings;
import studio.magemonkey.fabled.api.event.PhysicalDamageEvent;
import studio.magemonkey.fabled.dynamic.DynamicSkill;
/**
* Fabled © 2024
* studio.magemonkey.fabled.dynamic.trigger.BlockBreakTrigger
*/
public abstract class PhysicalTrigger implements Trigger {
/**
* {@inheritDoc}
*/
@Override
public Class getEvent() {
return PhysicalDamageEvent.class;
}
/**
* {@inheritDoc}
*/
@Override
public boolean shouldTrigger(final PhysicalDamageEvent event, final int level, final Settings settings) {
final String type = settings.getString("type", "both");
final double min = settings.getDouble("dmg-min");
final double max = settings.getDouble("dmg-max");
final boolean projectile = event.isProjectile();
return event.getDamage() >= min && event.getDamage() <= max &&
(type.equalsIgnoreCase("both") || type.equalsIgnoreCase("projectile") == projectile);
}
/**
* Handles applying other effects after the skill resolves
*
* @param event event details
* @param skill skill to resolve
*/
@Override
public void postProcess(final PhysicalDamageEvent event, final DynamicSkill skill) {
final double damage = skill.applyImmediateBuff(event.getDamage());
event.setDamage(damage);
}
boolean isUsingTarget(final Settings settings) {
return settings.getString("target", "true").equalsIgnoreCase("false");
}
}