com.sucy.skill.dynamic.trigger.DeathTrigger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of proskillapi Show documentation
Show all versions of proskillapi 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 com.sucy.skill.dynamic.trigger;
import com.sucy.skill.api.Settings;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDeathEvent;
import java.util.Map;
/**
* ProSkillAPI © 2023
* com.sucy.skill.dynamic.trigger.BlockBreakTrigger
*/
public class DeathTrigger implements Trigger {
/**
* {@inheritDoc}
*/
@Override
public String getKey() {
return "DEATH";
}
/**
* {@inheritDoc}
*/
@Override
public Class getEvent() {
return EntityDeathEvent.class;
}
/**
* {@inheritDoc}
*/
@Override
public boolean shouldTrigger(final EntityDeathEvent event, final int level, final Settings settings) {
return !isTargetingKiller(settings) || event.getEntity().getKiller() != null;
}
/**
* {@inheritDoc}
*/
@Override
public void setValues(final EntityDeathEvent event, final Map data) {}
/**
* {@inheritDoc}
*/
@Override
public LivingEntity getCaster(final EntityDeathEvent event) {
return event.getEntity();
}
/**
* {@inheritDoc}
*/
@Override
public LivingEntity getTarget(final EntityDeathEvent event, final Settings settings) {
return isTargetingKiller(settings) ? event.getEntity().getKiller() : event.getEntity();
}
private boolean isTargetingKiller(final Settings settings) {
return settings.getString("killer", "false").equalsIgnoreCase("true");
}
}