|
| 1 | +package cz.neumimto.rpg.spigot.bridges.denizen; |
| 2 | + |
| 3 | +import com.denizenscript.denizen.events.BukkitScriptEvent; |
| 4 | +import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; |
| 5 | +import com.denizenscript.denizencore.objects.ObjectTag; |
| 6 | +import com.denizenscript.denizencore.scripts.ScriptEntryData; |
| 7 | +import cz.neumimto.rpg.common.skills.PlayerSkillContext; |
| 8 | +import cz.neumimto.rpg.spigot.bridges.denizen.tags.CharacterTag; |
| 9 | +import cz.neumimto.rpg.spigot.bridges.denizen.tags.SkillContextTag; |
| 10 | +import cz.neumimto.rpg.spigot.entities.players.ISpigotCharacter; |
| 11 | + |
| 12 | +public class EntityCastSkillDenizenEvent extends BukkitScriptEvent { |
| 13 | + |
| 14 | + public ISpigotCharacter character; |
| 15 | + public PlayerSkillContext context; |
| 16 | + |
| 17 | + public static EntityCastSkillDenizenEvent instance; |
| 18 | + |
| 19 | + public EntityCastSkillDenizenEvent() { |
| 20 | + this.registerCouldMatcher("<entity> casts skill <'skill'>"); |
| 21 | + instance = this; |
| 22 | + } |
| 23 | + |
| 24 | + |
| 25 | + @Override |
| 26 | + public boolean matches(ScriptPath path) { |
| 27 | + String cmd = path.eventArgLowerAt(1); |
| 28 | + String arg0 = path.eventArgLowerAt(0); |
| 29 | + String arg2 = path.eventArgLowerAt(2); |
| 30 | + String arg3 = path.eventArgLowerAt(3); |
| 31 | + String attacker = cmd.equals("kills") ? arg0 : arg2.equals("by") ? arg3 : ""; |
| 32 | + String target = cmd.equals("kills") ? arg2 : arg0; |
| 33 | + |
| 34 | + // if (!attacker.isEmpty()) { |
| 35 | + // if (damager != null) { |
| 36 | + // if (!cause.asString().equals(attacker) && |
| 37 | + // !tryEntity(projectile, attacker) && !tryEntity(damager, attacker)) { |
| 38 | + // return false; |
| 39 | + // } |
| 40 | + // } |
| 41 | + // else if (!cause.asString().equals(attacker)) { |
| 42 | + // return false; |
| 43 | + // } |
| 44 | + // } |
| 45 | + |
| 46 | + // if (!tryEntity(entity, target)) { |
| 47 | + // return false; |
| 48 | + // } |
| 49 | + |
| 50 | + // if (!runInCheck(path, entity.getLocation())) { |
| 51 | + // return false; |
| 52 | + // } |
| 53 | + |
| 54 | + return super.matches(path); |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public String getName() { |
| 59 | + return "EntityCastsSkill"; |
| 60 | + } |
| 61 | + |
| 62 | + public ObjectTag getContext(String name) { |
| 63 | + switch (name) { |
| 64 | + case "caster": |
| 65 | + return new CharacterTag(character); |
| 66 | + case "skill_context": |
| 67 | + return new SkillContextTag(context, character); |
| 68 | + } |
| 69 | + return super.getContext(name); |
| 70 | + } |
| 71 | + |
| 72 | + public ScriptEntryData getScriptEntryData() { |
| 73 | + return new BukkitScriptEntryData(character.getPlayer()); |
| 74 | + } |
| 75 | + |
| 76 | + |
| 77 | +} |
0 commit comments