123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package me.km.effects;
- import me.km.KajetansMod;
- import me.km.environment.EnvironmentAPI;
- import me.km.snuviscript.ScriptEvents;
- import net.minecraft.entity.player.EntityPlayerMP;
- public abstract class ActiveEffectBase
- {
- public final boolean run(EntityPlayerMP p, int power, int mana, int cooldown, EffectCause cause)
- {
- if(cause != EffectCause.NOTHING)
- {
- if(KajetansMod.playerbank.getData(p).hasData("shadow"))
- {
- p.setInvisible(false);
- KajetansMod.playerbank.getData(p).removeData("shadow");
- }
- if(KajetansMod.playerbank.getData(p).hasData("silence"))
- {
- KajetansMod.effects.send(p, "Du kannst gerade keine Skills nutzen.");
- return false;
- }
- }
- // Effect-Event-Start
- String name = this.getClass().getSimpleName();
- PlayerUsesEffectEvent e = new PlayerUsesEffectEvent(p, power, mana, cooldown, cause, name);
- KajetansMod.scripts.getEvent(ScriptEvents.class).onEffectUse(e);
- if(e.isCanceled())
- {
- return false;
- }
- else
- {
- power = e.getPower();
- mana = e.getMana();
- cooldown = e.getCooldown();
- }
- // Effect-Event-End
- if(p.isCreative())
- {
- return executeEffect(p, power);
- }
- // cooldown check
- if(!KajetansMod.playerbank.getData(p).hasData(name))
- {
- if(mana > 0)
- {
- int currentMana = EnvironmentAPI.getMana(p);
- if(currentMana < mana)
- {
- KajetansMod.effects.send(p, "Du hast zu wenig Mana. (§a" + mana + "§r/§c" + mana + "§r)");
- return false;
- }
- }
- if(executeEffect(p, power))
- {
- if(cooldown > 0)
- {
- KajetansMod.playerbank.getData(p).addTimedData(name, cooldown);
- }
- if(mana >= 0)
- {
- EnvironmentAPI.changeMana(p, -mana);
- }
- return true;
- }
- return false;
- }
- KajetansMod.effects.send(p, "Der Cooldown läuft noch.");
- return false;
- }
-
- protected abstract boolean executeEffect(EntityPlayerMP p, int power);
- }
|