From 61781710f1c57798e2259b0b3463da7f9f44be7b Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:03:58 -0500 Subject: [PATCH] Implemented animation events and made some event classes abstract. --- src/api | 2 +- src/main/java/noppes/npcs/EventHooks.java | 69 +++++++---- .../noppes/npcs/constants/EnumScriptType.java | 18 ++- .../npcs/controllers/data/Animation.java | 16 +++ .../npcs/controllers/data/AnimationData.java | 45 ++++++-- .../npcs/controllers/data/DataScript.java | 5 +- .../npcs/scripted/event/AnimationEvent.java | 108 ++++++++++++++++++ .../npcs/scripted/event/BlockEvent.java | 2 +- .../npcs/scripted/event/CustomGuiEvent.java | 2 +- .../npcs/scripted/event/CustomNPCsEvent.java | 6 +- .../npcs/scripted/event/DialogEvent.java | 2 +- .../npcs/scripted/event/FactionEvent.java | 2 +- .../noppes/npcs/scripted/event/ItemEvent.java | 2 +- .../noppes/npcs/scripted/event/NpcEvent.java | 2 +- .../npcs/scripted/event/PartyEvent.java | 2 +- .../npcs/scripted/event/PlayerEvent.java | 2 +- .../npcs/scripted/event/ProjectileEvent.java | 13 ++- .../npcs/scripted/event/QuestEvent.java | 2 +- 18 files changed, 254 insertions(+), 46 deletions(-) create mode 100644 src/main/java/noppes/npcs/scripted/event/AnimationEvent.java diff --git a/src/api b/src/api index 51d086285..cd180e452 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 51d086285ed004b4790869d5d35b493439ced7fd +Subproject commit cd180e4520d766f927fb954433fd7812155a501f diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 5bb1dc4eb..5b63a426c 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -15,11 +15,12 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.api.IWorld; -import noppes.npcs.api.entity.IEntity; -import noppes.npcs.api.entity.IPlayer; -import noppes.npcs.api.entity.IProjectile; +import noppes.npcs.api.entity.*; +import noppes.npcs.api.event.IAnimationEvent; import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.gui.IItemSlot; +import noppes.npcs.api.handler.data.IAnimation; +import noppes.npcs.api.handler.data.IFrame; import noppes.npcs.api.item.IItemCustom; import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; @@ -119,7 +120,6 @@ public class EventHooks { return; noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INIT, event); npc.script.callScript(EnumScriptType.INIT, event); NpcAPI.EVENT_BUS.post(event); npc.advanced.soulStoneInit = false; @@ -130,7 +130,6 @@ public class EventHooks { return; noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TICK, event); npc.script.callScript(EnumScriptType.TICK, event); NpcAPI.EVENT_BUS.post(event); } @@ -140,7 +139,6 @@ public class EventHooks { return false; NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG, event); npc.script.callScript(EnumScriptType.DIALOG, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog()); return NpcAPI.EVENT_BUS.post(event); @@ -151,7 +149,6 @@ public class EventHooks { return; NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event); npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog()); NpcAPI.EVENT_BUS.post(event); @@ -162,7 +159,6 @@ public class EventHooks { return false; NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event); boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player); NpcAPI.EVENT_BUS.post(event); return result; @@ -172,7 +168,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); return NpcAPI.EVENT_BUS.post(event); @@ -182,7 +177,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event); npc.script.callScript(EnumScriptType.ATTACK_SWING, event); return NpcAPI.EVENT_BUS.post(event); } @@ -191,7 +185,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); npc.script.callScript(EnumScriptType.RANGED_LAUNCHED, event, "target", event.target); npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target); return NpcAPI.EVENT_BUS.post(event); @@ -202,7 +195,6 @@ public class EventHooks { return; NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event); npc.script.callScript(EnumScriptType.KILLS, event, "target", entity); NpcAPI.EVENT_BUS.post(event); } @@ -211,7 +203,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event); npc.script.callScript(EnumScriptType.TARGET, event); return NpcAPI.EVENT_BUS.post(event); } @@ -221,7 +212,6 @@ public class EventHooks { return false; NpcEvent.TargetLostEvent event = new NpcEvent.TargetLostEvent(npc.wrappedNPC, prevtarget, newTarget); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET_LOST, event); npc.script.callScript(EnumScriptType.TARGET_LOST, event); return NpcAPI.EVENT_BUS.post(event); } @@ -231,7 +221,6 @@ public class EventHooks { return; NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event); npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity); NpcAPI.EVENT_BUS.post(event); } @@ -240,7 +229,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event); npc.script.callScript(EnumScriptType.DAMAGED, event); return NpcAPI.EVENT_BUS.post(event); } @@ -249,7 +237,6 @@ public class EventHooks { if(npc == null || npc.wrappedNPC == null) return false; - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event); npc.script.callScript(EnumScriptType.KILLED, event); return NpcAPI.EVENT_BUS.post(event); } @@ -259,14 +246,12 @@ public class EventHooks { return; NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TIMER, event); npc.script.callScript(EnumScriptType.TIMER, event); NpcAPI.EVENT_BUS.post(event); } public static void onProjectileTick(EntityProjectile projectile) { ProjectileEvent.UpdateEvent event = new ProjectileEvent.UpdateEvent((IProjectile) NpcAPI.Instance().getIEntity(projectile)); - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_TICK, event); for(ScriptContainer script : projectile.scripts) { if(script.isValid()) { script.run(EnumScriptType.PROJECTILE_TICK, event); @@ -284,7 +269,6 @@ public class EventHooks { } public static void onProjectileImpact(EntityProjectile projectile, ProjectileEvent.ImpactEvent event) { - ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_IMPACT, event); for(ScriptContainer script : projectile.scripts) { if(script.isValid()) { script.run(EnumScriptType.PROJECTILE_IMPACT, event); @@ -805,4 +789,49 @@ public class EventHooks { handler.callScript(EnumScriptType.PARTY_DISBAND, event); NpcAPI.EVENT_BUS.post(event); } + + private static boolean postAnimationEvent(IAnimationEvent event) { + IScriptHandler handler; + IAnimatable animatable = event.getAnimation().getParent().getEntity(); + if (animatable instanceof ICustomNpc) { + EntityNPCInterface npc = (EntityNPCInterface) ((ICustomNpc) animatable).getMCEntity(); + handler = npc.script; + } else { + handler = ScriptController.Instance.playerScripts; + } + + if (handler.isClient()) + return false; + + handler.callScript(event.getHookName(), (Event) event); + return NpcAPI.EVENT_BUS.post((Event) event); + } + + public static boolean onAnimationStarted(IAnimation animation) { + if (animation.getParent() == null || animation.getParent().getEntity() == null) { + return false; + } + return postAnimationEvent(new AnimationEvent.Started(animation)); + } + + public static void onAnimationEnded(IAnimation animation) { + if (animation.getParent() == null || animation.getParent().getEntity() == null) { + return; + } + postAnimationEvent(new AnimationEvent.Ended(animation)); + } + + public static void onAnimationFrameEntered(IAnimation animation, IFrame frame) { + if (frame == null || animation.getParent() == null || animation.getParent().getEntity() == null) { + return; + } + postAnimationEvent(new AnimationEvent.FrameEvent.Entered(animation, frame)); + } + + public static void onAnimationFrameExited(IAnimation animation, IFrame frame) { + if (frame == null || animation.getParent() == null || animation.getParent().getEntity() == null) { + return; + } + postAnimationEvent(new AnimationEvent.FrameEvent.Exited(animation, frame)); + } } diff --git a/src/main/java/noppes/npcs/constants/EnumScriptType.java b/src/main/java/noppes/npcs/constants/EnumScriptType.java index a8f233f47..fd968a716 100644 --- a/src/main/java/noppes/npcs/constants/EnumScriptType.java +++ b/src/main/java/noppes/npcs/constants/EnumScriptType.java @@ -99,13 +99,27 @@ public enum EnumScriptType { PARTY_INVITE("partyInvite"), PARTY_KICK("partyKick"), PARTY_LEAVE("partyLeave"), - PARTY_DISBAND("partyDisband"); + PARTY_DISBAND("partyDisband"), + + ANIMATION_START("animationStart"), + ANIMATION_END("animationEnd"), + ANIMATION_FRAME_ENTER("frameEnter"), + ANIMATION_FRAME_EXIT("frameExit"); public String function; public static EnumScriptType valueOfIgnoreCase(String channelName) { channelName = channelName.toUpperCase(); - return valueOf(channelName); + try { + return valueOf(channelName); + } catch (IllegalArgumentException exception) { + for (EnumScriptType value : EnumScriptType.values()) { + if (value.function.toUpperCase().equals(channelName)) { + return value; + } + } + throw exception; + } } private EnumScriptType(String function) { diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java index 4e2ce3c8e..0b9ae8fd7 100644 --- a/src/main/java/noppes/npcs/controllers/data/Animation.java +++ b/src/main/java/noppes/npcs/controllers/data/Animation.java @@ -1,10 +1,13 @@ package noppes.npcs.controllers.data; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import noppes.npcs.EventHooks; import noppes.npcs.api.handler.data.IAnimation; +import noppes.npcs.api.handler.data.IAnimationData; import noppes.npcs.api.handler.data.IFrame; import noppes.npcs.constants.EnumAnimationPart; import noppes.npcs.controllers.AnimationController; @@ -48,6 +51,10 @@ public class Animation implements IAnimation { this.id = id; } + public IAnimationData getParent() { + return this.parent; + } + public IFrame currentFrame() { return currentFrame < frames.size() ? frames.get(currentFrame) : null; } @@ -237,6 +244,8 @@ public class Animation implements IAnimation { this.currentFrameTime++; if (this.currentFrameTime == this.currentFrame().getDuration()) { + EventHooks.onAnimationFrameExited(this, this.currentFrame()); + Frame prevFrame = (Frame) this.currentFrame(); Frame nextFrame = null; this.currentFrameTime = 0; @@ -246,6 +255,13 @@ public class Animation implements IAnimation { } else if (this.loop >= 0 && this.loop < this.frames.size()) { this.currentFrame = this.loop; } + + if (this.currentFrame() != null) { + EventHooks.onAnimationFrameEntered(this, this.currentFrame()); + } else { + EventHooks.onAnimationEnded(this); + } + if (nextFrame != null) { for (EnumAnimationPart part : EnumAnimationPart.values()) { if (prevFrame.frameParts.containsKey(part) && nextFrame.frameParts.containsKey(part)) { diff --git a/src/main/java/noppes/npcs/controllers/data/AnimationData.java b/src/main/java/noppes/npcs/controllers/data/AnimationData.java index 3bfb538c5..d8d4a07f7 100644 --- a/src/main/java/noppes/npcs/controllers/data/AnimationData.java +++ b/src/main/java/noppes/npcs/controllers/data/AnimationData.java @@ -2,24 +2,22 @@ package noppes.npcs.controllers.data; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; -import noppes.npcs.CommonProxy; -import noppes.npcs.CustomNpcs; -import noppes.npcs.DataDisplay; -import noppes.npcs.Server; +import noppes.npcs.*; +import noppes.npcs.api.entity.IAnimatable; +import noppes.npcs.api.entity.ICustomNpc; +import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.handler.data.IAnimation; import noppes.npcs.api.handler.data.IAnimationData; -import noppes.npcs.client.ClientCacheHandler; import noppes.npcs.constants.EnumAnimationPart; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.NpcAPI; import java.util.Arrays; import java.util.HashSet; @@ -34,6 +32,9 @@ public class AnimationData implements IAnimationData { public Animation animation; public boolean allowAnimation = false; + private Animation sentAnimation; + private boolean isClientAnimating; + private final HashSet cachedAnimationIDs = new HashSet<>(); //Client-side values @@ -50,6 +51,21 @@ public class AnimationData implements IAnimationData { } } + public IAnimatable getEntity() { + if (this.parent instanceof DataDisplay) { + EntityNPCInterface npc = ((DataDisplay)this.parent).npc; + return (ICustomNpc) NpcAPI.Instance().getIEntity(npc); + } else { + EntityPlayer player; + if (this.parent instanceof PlayerData) { + player = ((PlayerData) this.parent).player; + } else { + player = (EntityPlayer) this.parent; + } + return (IPlayer) NpcAPI.Instance().getIEntity(player); + } + } + public void updateClient() { this.updateClient(new EntityPlayer[0]); } @@ -58,6 +74,21 @@ public class AnimationData implements IAnimationData { EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null; float range = parent instanceof PlayerData ? 160 : 60; if (sendingEntity != null) { + boolean prevIsClientAnimating = this.isClientAnimating && this.sentAnimation.currentFrame() != null; + this.isClientAnimating = this.allowAnimation && this.animation != null; + if (prevIsClientAnimating && (!this.isClientAnimating || this.animation != this.sentAnimation)) { + EventHooks.onAnimationEnded(this.sentAnimation); + } + if (this.isClientAnimating) { + this.sentAnimation = this.animation; + } + + if (this.animation != null && this.allowAnimation) { + if (EventHooks.onAnimationStarted(this.animation)) + return; + EventHooks.onAnimationFrameEntered(this.animation, this.animation.currentFrame()); + } + if (!CustomNpcs.proxy.hasClient()) { CommonProxy.serverPlayingAnimations.add(this.animation); } diff --git a/src/main/java/noppes/npcs/controllers/data/DataScript.java b/src/main/java/noppes/npcs/controllers/data/DataScript.java index e2bd8688f..d567f11d2 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/DataScript.java @@ -236,13 +236,14 @@ public class DataScript implements INpcScriptHandler { @Override public void callScript(EnumScriptType type, Event event) { + ScriptController.Instance.globalNpcScripts.callScript(type, event); callScript(type, event, "$$IGNORED$$", null); } @Override public void callScript(String hookName, Event event) { try { - EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName); + EnumScriptType enumScriptType = EnumScriptType.valueOfIgnoreCase(hookName); this.callScript(enumScriptType, event); } catch (IllegalArgumentException ignored) {} } @@ -305,4 +306,4 @@ public class DataScript implements INpcScriptHandler { public Collection getNPCScripts() { return this.scripts.values(); } -} \ No newline at end of file +} diff --git a/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java b/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java new file mode 100644 index 000000000..1690f8e57 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/event/AnimationEvent.java @@ -0,0 +1,108 @@ +package noppes.npcs.scripted.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import noppes.npcs.api.entity.IAnimatable; +import noppes.npcs.api.event.IAnimationEvent; +import noppes.npcs.api.handler.data.IAnimation; +import noppes.npcs.api.handler.data.IAnimationData; +import noppes.npcs.api.handler.data.IFrame; +import noppes.npcs.constants.EnumScriptType; +import noppes.npcs.controllers.data.Animation; +import noppes.npcs.controllers.data.Frame; + +public abstract class AnimationEvent extends CustomNPCsEvent implements IAnimationEvent { + protected final IAnimation animation; + protected final IAnimationData animationData; + protected final IAnimatable entity; + + public AnimationEvent(IAnimation animation) { + this.animation = animation; + this.animationData = animation.getParent(); + this.entity = this.animationData.getEntity(); + } + + @Override + public IAnimation getAnimation() { + return this.animation; + } + + @Override + public IAnimationData getAnimationData() { + return this.animationData; + } + + @Override + public IAnimatable getEntity() { + return this.entity; + } + + @Cancelable + public static class Started extends AnimationEvent { + + public Started(IAnimation animation) { + super(animation); + } + + @Override + public String getHookName() { + return EnumScriptType.ANIMATION_START.function; + } + } + + public static class Ended extends AnimationEvent { + + public Ended(IAnimation animation) { + super(animation); + } + + @Override + public String getHookName() { + return EnumScriptType.ANIMATION_END.function; + } + } + + public static abstract class FrameEvent extends AnimationEvent implements IFrameEvent { + private final IFrame frame; + private final int index; + + public FrameEvent(IAnimation animation, IFrame frame) { + super(animation); + this.frame = frame; + this.index = ((Animation)this.getAnimation()).frames.indexOf((Frame) this.frame); + } + + @Override + public int getIndex() { + return this.index; + } + + @Override + public IFrame getFrame() { + return this.frame; + } + + public static class Entered extends FrameEvent { + + public Entered(IAnimation animation, IFrame frame) { + super(animation, frame); + } + + @Override + public String getHookName() { + return EnumScriptType.ANIMATION_FRAME_ENTER.function; + } + } + + public static class Exited extends FrameEvent { + + public Exited(IAnimation animation, IFrame frame) { + super(animation, frame); + } + + @Override + public String getHookName() { + return EnumScriptType.ANIMATION_FRAME_EXIT.function; + } + } + } +} diff --git a/src/main/java/noppes/npcs/scripted/event/BlockEvent.java b/src/main/java/noppes/npcs/scripted/event/BlockEvent.java index 3367a1699..48a03ec9e 100644 --- a/src/main/java/noppes/npcs/scripted/event/BlockEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/BlockEvent.java @@ -11,7 +11,7 @@ import noppes.npcs.api.event.IBlockEvent; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; -public class BlockEvent extends CustomNPCsEvent implements IBlockEvent { +public abstract class BlockEvent extends CustomNPCsEvent implements IBlockEvent { public IBlock block; public BlockEvent(IBlock block){ this.block = block; diff --git a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java index 130a6657c..a62c02156 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java @@ -10,7 +10,7 @@ import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; -public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { +public abstract class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { public final IPlayer player; public final ICustomGui gui; diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index 0a0dfd2bb..2e77b5aff 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -9,12 +9,10 @@ import noppes.npcs.api.event.ICustomNPCsEvent; import noppes.npcs.api.handler.data.INaturalSpawn; import noppes.npcs.constants.EnumScriptType; -public class CustomNPCsEvent extends Event implements ICustomNPCsEvent { +public abstract class CustomNPCsEvent extends Event implements ICustomNPCsEvent { public final AbstractNpcAPI API = AbstractNpcAPI.Instance(); - public String getHookName() { - return "CNPCEvent"; - } + public abstract String getHookName(); public CustomNPCsEvent() { } diff --git a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java index 84ace0ee7..a3dfb671b 100644 --- a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java @@ -6,7 +6,7 @@ import noppes.npcs.api.event.IDialogEvent; import noppes.npcs.api.handler.data.IDialog; import noppes.npcs.constants.EnumScriptType; -public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { +public abstract class DialogEvent extends CustomNPCsEvent implements IDialogEvent { public final IDialog dialog; public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java index 2741b669b..ed0aca4a1 100644 --- a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java @@ -6,7 +6,7 @@ import noppes.npcs.api.event.IFactionEvent; import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.constants.EnumScriptType; -public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { +public abstract class FactionEvent extends CustomNPCsEvent implements IFactionEvent { public final IFaction faction; public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 99e959814..8f90f8e94 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -7,7 +7,7 @@ import noppes.npcs.api.event.IItemEvent; import noppes.npcs.api.item.IItemCustom; import noppes.npcs.constants.EnumScriptType; -public class ItemEvent extends CustomNPCsEvent implements IItemEvent { +public abstract class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IItemCustom item; public ItemEvent(IItemCustom item) { diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 41c03b803..14c5e9b38 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -20,7 +20,7 @@ import noppes.npcs.scripted.NpcAPI; import java.util.ArrayList; -public class NpcEvent extends CustomNPCsEvent implements INpcEvent { +public abstract class NpcEvent extends CustomNPCsEvent implements INpcEvent { public final ICustomNpc npc; public NpcEvent(ICustomNpc npc) { diff --git a/src/main/java/noppes/npcs/scripted/event/PartyEvent.java b/src/main/java/noppes/npcs/scripted/event/PartyEvent.java index d1df03e8d..adaacc81f 100644 --- a/src/main/java/noppes/npcs/scripted/event/PartyEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PartyEvent.java @@ -7,7 +7,7 @@ import noppes.npcs.api.handler.data.IParty; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.constants.EnumScriptType; -public class PartyEvent extends CustomNPCsEvent implements IPartyEvent { +public abstract class PartyEvent extends CustomNPCsEvent implements IPartyEvent { public final IQuest quest; public final IParty party; diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index e181668ac..0a57d95a5 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -18,7 +18,7 @@ import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; -public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { +public abstract class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public final IPlayer player; public PlayerEvent(IPlayer player) { diff --git a/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java b/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java index e485396b5..060edfbe7 100644 --- a/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java @@ -4,8 +4,9 @@ import noppes.npcs.api.IBlock; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IProjectile; import noppes.npcs.api.event.IProjectileEvent; +import noppes.npcs.constants.EnumScriptType; -public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent { +public abstract class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent { public IProjectile projectile; public IEntity source; @@ -29,6 +30,11 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent public UpdateEvent(IProjectile projectile) { super(projectile); } + + @Override + public String getHookName() { + return EnumScriptType.PROJECTILE_TICK.function; + } } /** @@ -62,5 +68,10 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent return (IBlock) target; return null; } + + @Override + public String getHookName() { + return EnumScriptType.PROJECTILE_IMPACT.function; + } } } diff --git a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java index 264e6f8c8..c5261f951 100644 --- a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java @@ -7,7 +7,7 @@ import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.api.item.IItemStack; import noppes.npcs.constants.EnumScriptType; -public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { +public abstract class QuestEvent extends CustomNPCsEvent implements IQuestEvent { public final IQuest quest; public final IPlayer player;