From 681f62eeb692f7fe57a6560c764a2f689efbf21d Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Thu, 24 Nov 2022 16:46:20 -0600 Subject: [PATCH] Added getHookName() function --- .../npcs/api/event/ICustomNPCsEvent.java | 2 + src/main/java/noppes/npcs/EventHooks.java | 2 +- .../noppes/npcs/constants/EnumScriptType.java | 9 +- .../npcs/scripted/event/CustomGuiEvent.java | 31 +++- .../npcs/scripted/event/CustomNPCsEvent.java | 9 + .../npcs/scripted/event/DialogEvent.java | 19 ++ .../npcs/scripted/event/FactionEvent.java | 9 + .../npcs/scripted/event/ForgeEvent.java | 17 ++ .../noppes/npcs/scripted/event/ItemEvent.java | 49 ++++++ .../noppes/npcs/scripted/event/NpcEvent.java | 57 ++++++ .../npcs/scripted/event/PlayerEvent.java | 165 ++++++++++++++++++ .../npcs/scripted/event/QuestEvent.java | 17 ++ 12 files changed, 383 insertions(+), 3 deletions(-) diff --git a/src/api/java/noppes/npcs/api/event/ICustomNPCsEvent.java b/src/api/java/noppes/npcs/api/event/ICustomNPCsEvent.java index 31e8f4542..c25601265 100644 --- a/src/api/java/noppes/npcs/api/event/ICustomNPCsEvent.java +++ b/src/api/java/noppes/npcs/api/event/ICustomNPCsEvent.java @@ -6,6 +6,8 @@ import noppes.npcs.api.handler.data.INaturalSpawn; public interface ICustomNPCsEvent { + String getHookName(); + @Cancelable interface CNPCNaturalSpawnEvent extends ICustomNPCsEvent { INaturalSpawn getNaturalSpawn(); diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 1186ce2f3..1a83606ab 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -519,7 +519,7 @@ public class EventHooks { public static boolean onCNPCNaturalSpawn(CustomNPCsEvent.CNPCNaturalSpawnEvent event) { ForgeDataScript handler = ScriptController.Instance.forgeScripts; if (handler.isEnabled()) { - handler.callScript("onCNPCNaturalSpawn", event); + handler.callScript(EnumScriptType.CNPC_NATURAL_SPAWN, event); return NpcAPI.EVENT_BUS.post(event); } return true; diff --git a/src/main/java/noppes/npcs/constants/EnumScriptType.java b/src/main/java/noppes/npcs/constants/EnumScriptType.java index f38458e15..a6f3aa704 100644 --- a/src/main/java/noppes/npcs/constants/EnumScriptType.java +++ b/src/main/java/noppes/npcs/constants/EnumScriptType.java @@ -45,15 +45,19 @@ public enum EnumScriptType { PROJECTILE_IMPACT("projectileImpact"), LEVEL_UP("levelUp"), KEY_PRESSED("keyPressed"), + QUEST_EVENT("questEvent"), QUEST_START("questStart"), QUEST_COMPLETED("questCompleted"), QUEST_TURNIN("questTurnIn"), + FACTION_EVENT("factionEvent"), FACTION_POINTS("factionPoints"), + DIALOG_EVENT("dialogEvent"), DIALOG_OPEN("dialogOpen"), DIALOG_OPTION("dialogOption"), CUSTOM_CHEST_CLOSED("customChestClosed"), CUSTOM_CHEST_CLICKED("customChestClicked"), SCRIPT_COMMAND("scriptCommand"), + CUSTOM_GUI_EVENT("customGuiEvent"), CUSTOM_GUI_CLOSED("customGuiClosed"), CUSTOM_GUI_BUTTON("customGuiButton"), CUSTOM_GUI_SLOT("customGuiSlot"), @@ -79,9 +83,12 @@ public enum EnumScriptType { RESPAWN("respawn"), CHANGED_DIM("changedDim"), BREAK_BLOCK("breakBlock"), + FORGE_EVENT("forgeEvent"), FORGE_INIT("forgeInit"), FORGE_ENTITY("forgeEntity"), - FORGE_WORLD("forgeWorld"); + FORGE_WORLD("forgeWorld"), + CNPC_NATURAL_SPAWN("onCNPCNaturalSpawn"), + CUSTOM_ITEM_EVENT("customItemEvent"); public String function; diff --git a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java index 2d70ebe85..874910c52 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java @@ -6,8 +6,9 @@ import noppes.npcs.api.event.ICustomGuiEvent; import noppes.npcs.api.gui.ICustomGui; import noppes.npcs.api.item.IItemStack; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.constants.EnumScriptType; -public class CustomGuiEvent extends Event implements ICustomGuiEvent { +public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent { public final IPlayer player; public final ICustomGui gui; @@ -16,6 +17,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.gui = gui; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_EVENT.function; + } + public IPlayer getPlayer() { return this.player; } @@ -36,6 +41,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.buttonId = buttonId; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_BUTTON.function; + } + public int getId() { return this.buttonId; } @@ -49,6 +58,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.textfieldId = textfieldId; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_TEXTFIELD.function; + } + public int getId() { return this.textfieldId; } @@ -58,6 +71,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { public CloseEvent(IPlayer player, ICustomGui gui) { super(player, gui); } + + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_CLOSED.function; + } } public static class ScrollEvent extends CustomGuiEvent implements ICustomGuiEvent.ScrollEvent { @@ -74,6 +91,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.scrollIndex = scrollIndex; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_SCROLL.function; + } + public int getId() { return this.scrollId; } @@ -101,6 +122,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.stack = stack; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_SLOT.function; + } + public int getId() { return this.slotId; } @@ -128,6 +153,10 @@ public class CustomGuiEvent extends Event implements ICustomGuiEvent { this.clickType = clickType; } + public String getHookName() { + return EnumScriptType.CUSTOM_GUI_SLOT_CLICKED.function; + } + public int getId() { return this.slotId; } diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index 8d8be1de8..e62d46d47 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -11,10 +11,15 @@ import noppes.npcs.api.AbstractNpcAPI; import noppes.npcs.api.IPos; 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 final AbstractNpcAPI API = AbstractNpcAPI.Instance(); + public String getHookName() { + return "CNPCEvent"; + } + public CustomNPCsEvent() { } @@ -43,6 +48,10 @@ public class CustomNPCsEvent extends Event implements ICustomNPCsEvent { this.airSpawnPassed = airSpawnPassed; } + public String getHookName() { + return EnumScriptType.CNPC_NATURAL_SPAWN.function; + } + public INaturalSpawn getNaturalSpawn() { return this.naturalSpawn; } diff --git a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java index 7af764b16..82588d06a 100644 --- a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.event.IDialogEvent; import noppes.npcs.api.handler.data.IDialog; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.constants.EnumScriptType; public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { public final IDialog dialog; @@ -22,11 +23,19 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { return dialog; } + public String getHookName() { + return EnumScriptType.DIALOG_EVENT.function; + } + @Cancelable public static class DialogOpen extends DialogEvent implements IDialogEvent.DialogOpen { public DialogOpen(IPlayer player, IDialog dialog) { super(player, dialog); } + + public String getHookName() { + return EnumScriptType.DIALOG_OPEN.function; + } } @Cancelable @@ -34,11 +43,21 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent { public DialogOption(IPlayer player, IDialog dialog) { super(player, dialog); } + + public String getHookName() { + return EnumScriptType.DIALOG_OPTION.function; + } + } public static class DialogClosed extends DialogEvent implements IDialogEvent.DialogClosed { public DialogClosed(IPlayer player, IDialog dialog){ super(player, dialog); } + + public String getHookName() { + return EnumScriptType.DIALOG_CLOSE.function; + } + } } diff --git a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java index 6635fd1af..21cdd1e64 100644 --- a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.Cancelable; import noppes.npcs.api.event.IFactionEvent; import noppes.npcs.api.handler.data.IFaction; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.constants.EnumScriptType; public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { public final IFaction faction; @@ -22,6 +23,10 @@ public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { return faction; } + public String getHookName() { + return EnumScriptType.FACTION_EVENT.function; + } + @Cancelable public static class FactionPoints extends FactionEvent implements IFactionEvent.FactionPoints { public boolean decrease; @@ -33,6 +38,10 @@ public class FactionEvent extends CustomNPCsEvent implements IFactionEvent { this.points = points; } + public String getHookName() { + return EnumScriptType.FACTION_POINTS.function; + } + public boolean decreased() { return decrease; } diff --git a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java index 683e3eb1d..a77e13b43 100644 --- a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java @@ -10,6 +10,7 @@ import cpw.mods.fml.common.eventhandler.Event; import noppes.npcs.api.IWorld; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.event.IForgeEvent; +import noppes.npcs.constants.EnumScriptType; @Cancelable public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { @@ -23,6 +24,10 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { return event; } + public String getHookName() { + return EnumScriptType.FORGE_EVENT.function; + } + @Cancelable public static class WorldEvent extends ForgeEvent implements IForgeEvent.WorldEvent { public final IWorld world; @@ -32,6 +37,10 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { this.world = world; } + public String getHookName() { + return EnumScriptType.FORGE_WORLD.function; + } + public IWorld getWorld() { return world; } @@ -46,6 +55,10 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { this.entity = entity; } + public String getHookName() { + return EnumScriptType.FORGE_ENTITY.function; + } + public IEntity getEntity() { return entity; } @@ -55,5 +68,9 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent { public InitEvent() { super((Event)null); } + + public String getHookName() { + return EnumScriptType.FORGE_INIT.function; + } } } diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index fd1d0522e..de8542cea 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -5,6 +5,7 @@ import noppes.npcs.api.event.IItemEvent; import noppes.npcs.api.item.IItemCustom; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.constants.EnumScriptType; public class ItemEvent extends CustomNPCsEvent implements IItemEvent { public final IItemCustom item; @@ -17,10 +18,18 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { return item; } + public String getHookName() { + return EnumScriptType.CUSTOM_ITEM_EVENT.function; + } + public static class InitEvent extends ItemEvent implements IItemEvent.InitEvent { public InitEvent(IItemCustom item) { super(item); } + + public String getHookName() { + return EnumScriptType.INIT.function; + } } public static class UpdateEvent extends ItemEvent implements IItemEvent.UpdateEvent { @@ -31,6 +40,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.entity = entity; } + public String getHookName() { + return EnumScriptType.TICK.function; + } + public IEntity getEntity() { return entity; } @@ -47,6 +60,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.player = player; } + public String getHookName() { + return EnumScriptType.TOSSED.function; + } + public IEntity getEntity() { return entity; } @@ -64,6 +81,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.player = player; } + public String getHookName() { + return EnumScriptType.PICKEDUP.function; + } + public IPlayer getPlayer() { return player; } @@ -78,6 +99,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.entity = entity; } + public String getHookName() { + return EnumScriptType.SPAWN.function; + } + public IEntity getEntity() { return entity; } @@ -96,6 +121,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.player = player; } + public String getHookName() { + return EnumScriptType.INTERACT.function; + } + public int getType() { return type; } @@ -122,6 +151,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.swingingEntity = swingingEntity; } + public String getHookName() { + return EnumScriptType.ATTACK.function; + } + public int getType() { return type; } @@ -145,6 +178,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.START_USING_ITEM.function; + } + public IPlayer getPlayer() { return player; } @@ -163,6 +200,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.USING_ITEM.function; + } + public IPlayer getPlayer() { return player; } @@ -181,6 +222,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.STOP_USING_ITEM.function; + } + public IPlayer getPlayer() { return player; } @@ -199,6 +244,10 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.FINISH_USING_ITEM.function; + } + public IPlayer getPlayer() { return player; } diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index dd4f625bb..64c758943 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -14,6 +14,7 @@ import net.minecraft.util.DamageSource; import noppes.npcs.api.IDamageSource; import noppes.npcs.api.event.INpcEvent; import noppes.npcs.api.handler.data.IDialog; +import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.data.Dialog; import noppes.npcs.api.entity.ICustomNpc; import noppes.npcs.api.entity.IEntity; @@ -43,6 +44,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.id = id; } + public String getHookName() { + return EnumScriptType.TIMER.function; + } + public int getId(){ return id; } @@ -56,6 +61,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.entity = NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.COLLIDE.function; + } + public IEntity getEntity() { return entity; } @@ -81,6 +90,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.damagesource = damagesource; } + public String getHookName() { + return EnumScriptType.DAMAGED.function; + } + /** * @return The source of the damage */ @@ -132,6 +145,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.damage = damage; } + public String getHookName() { + return EnumScriptType.RANGED_LAUNCHED.function; + } + /** * @return The source of the damage * @deprecated @@ -174,6 +191,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.damage = damage; } + public String getHookName() { + return EnumScriptType.ATTACK_MELEE.function; + } + /** * @return The source of the damage * @deprecated @@ -213,6 +234,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.KILLS.function; + } + public IEntityLivingBase getEntity() { return entity; } @@ -241,6 +266,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.expDropped = expDropped; } + public String getHookName() { + return EnumScriptType.KILLED.function; + } + /** * @return The source of the damage */ @@ -283,6 +312,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); } + public String getHookName() { + return EnumScriptType.INTERACT.function; + } + public IPlayer getPlayer() { return player; } @@ -309,6 +342,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.option = optionId; } + public String getHookName() { + return EnumScriptType.DIALOG.function; + } + public IPlayer getPlayer() { return player; } @@ -353,6 +390,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.option = optionId; } + public String getHookName() { + return EnumScriptType.DIALOG_CLOSE.function; + } + public IPlayer getPlayer() { return player; } @@ -386,6 +427,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.TARGET_LOST.function; + } + public IEntityLivingBase getTarget() { return entity; } @@ -400,6 +445,10 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.TARGET.function; + } + public void setTarget(IEntityLivingBase entity){ this.entity = entity; } @@ -416,11 +465,19 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public UpdateEvent(ICustomNpc npc) { super(npc); } + + public String getHookName() { + return EnumScriptType.TICK.function; + } } public static class InitEvent extends NpcEvent implements INpcEvent.InitEvent { public InitEvent(ICustomNpc npc) { super(npc); } + + public String getHookName() { + return EnumScriptType.INIT.function; + } } } diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index c30831940..2caedacaa 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -20,6 +20,7 @@ import noppes.npcs.api.entity.IEntityLivingBase; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.event.IPlayerEvent; import noppes.npcs.api.item.IItemStack; +import noppes.npcs.constants.EnumScriptType; import noppes.npcs.scripted.NpcAPI; public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { @@ -42,6 +43,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.message = message; } + public String getHookName() { + return EnumScriptType.CHAT.function; + } + public void setMessage(String message) { this.message = message; } @@ -71,6 +76,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.keysDown = heldKeys; } + public String getHookName() { + return EnumScriptType.KEY_PRESSED.function; + } + public int getKey() { return key; } @@ -123,6 +132,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.keysDown = heldKeys; } + public String getHookName() { + return EnumScriptType.MOUSE_CLICKED.function; + } + public int getButton() { return button; } @@ -164,6 +177,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.amount = orb.xpValue; } + public String getHookName() { + return EnumScriptType.PICKUP_XP.function; + } + public int getAmount() { return amount; } @@ -177,6 +194,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.change = change; } + public String getHookName() { + return EnumScriptType.LEVEL_UP.function; + } + public int getChange() { return change; } @@ -186,18 +207,30 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public LogoutEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.LOGOUT.function; + } } public static class LoginEvent extends PlayerEvent implements IPlayerEvent.LoginEvent { public LoginEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.LOGIN.function; + } } public static class RespawnEvent extends PlayerEvent implements IPlayerEvent.RespawnEvent { public RespawnEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.RESPAWN.function; + } } public static class ChangedDimension extends PlayerEvent implements IPlayerEvent.ChangedDimension { @@ -210,6 +243,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.toDim = toDim; } + public String getHookName() { + return EnumScriptType.CHANGED_DIM.function; + } + public int getFromDim() { return fromDim; } @@ -227,6 +264,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.id = id; } + public String getHookName() { + return EnumScriptType.TIMER.function; + } + public int getId() { return id; } @@ -245,6 +286,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } + public String getHookName() { + return EnumScriptType.ATTACKED.function; + } + public IDamageSource getDamageSource() { return damageSource; } @@ -272,6 +317,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } + public String getHookName() { + return EnumScriptType.DAMAGED.function; + } + public IDamageSource getDamageSource() { return damageSource; } @@ -290,6 +339,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public LightningEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.LIGHTNING.function; + } } @Cancelable @@ -305,6 +358,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.volume = volume; } + public String getHookName() { + return EnumScriptType.PLAYSOUND.function; + } + public String getName() { return name; } @@ -327,6 +384,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.distance = distance; } + public String getHookName() { + return EnumScriptType.FALL.function; + } + public float getDistance() { return distance; } @@ -336,6 +397,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public JumpEvent(IPlayer player){ super(player); } + + public String getHookName() { + return EnumScriptType.JUMP.function; + } } public static class KilledEntityEvent extends PlayerEvent implements IPlayerEvent.KilledEntityEvent { @@ -346,6 +411,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.KILLS.function; + } + public IEntityLivingBase getEntity() { return entity; } @@ -363,6 +432,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.source = NpcAPI.Instance().getIEntity(entity); } + public String getHookName() { + return EnumScriptType.KILLED.function; + } + public IDamageSource getDamageSource() { return damageSource; } @@ -387,6 +460,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.charge = charge; } + public String getHookName() { + return EnumScriptType.RANGED_LAUNCHED.function; + } + public IItemStack getBow() { return bow; } @@ -409,6 +486,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } + public String getHookName() { + return EnumScriptType.ATTACK.function; + } + public IDamageSource getDamageSource() { return damageSource; } @@ -435,6 +516,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } + public String getHookName() { + return EnumScriptType.DAMAGED_ENTITY.function; + } + public IDamageSource getDamageSource() { return damageSource; } @@ -456,6 +541,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.container = container; } + public String getHookName() { + return EnumScriptType.CONTAINER_CLOSED.function; + } + public IContainer getContainer() { return container; } @@ -469,6 +558,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.container = container; } + public String getHookName() { + return EnumScriptType.CONTAINER_OPEN.function; + } + public IContainer getContainer() { return container; } @@ -483,6 +576,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.item = item; } + public String getHookName() { + return EnumScriptType.PICKUP.function; + } + public IItemStack getItem() { return item; } @@ -497,6 +594,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.items = items; } + public String getHookName() { + return EnumScriptType.DROP.function; + } + public IItemStack[] getItems() { return items; } @@ -511,6 +612,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.item = item; } + public String getHookName() { + return EnumScriptType.TOSS.function; + } + public IItemStack getItem() { return item; } @@ -527,6 +632,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.target = target; } + public String getHookName() { + return EnumScriptType.INTERACT.function; + } + public int getType() { return type; } @@ -540,12 +649,20 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public UpdateEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.TICK.function; + } } public static class InitEvent extends PlayerEvent implements IPlayerEvent.InitEvent { public InitEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.INIT.function; + } } public static class StartUsingItem extends PlayerEvent implements IPlayerEvent.StartUsingItem { @@ -559,6 +676,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.START_USING_ITEM.function; + } + public IItemStack getItem() { return item; } @@ -578,6 +699,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.USING_ITEM.function; + } + public IItemStack getItem() { return item; } @@ -597,6 +722,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.STOP_USING_ITEM.function; + } + public IItemStack getItem() { return item; } @@ -616,6 +745,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.duration = duration; } + public String getHookName() { + return EnumScriptType.FINISH_USING_ITEM.function; + } + public IItemStack getItem() { return item; } @@ -636,6 +769,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.exp = exp; } + public String getHookName() { + return EnumScriptType.BREAK_BLOCK.function; + } + public IBlock getBlock() { return block; } @@ -659,6 +796,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.z = z; } + public String getHookName() { + return EnumScriptType.USE_HOE.function; + } + public IItemStack getHoe() { return hoe; } @@ -684,6 +825,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.setSpawn = setSpawn; } + public String getHookName() { + return EnumScriptType.WAKE_UP.function; + } + public boolean setSpawn() { return setSpawn; } @@ -701,6 +846,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.z = z; } + public String getHookName() { + return EnumScriptType.SLEEP.function; + } + public int getX() { return x; } @@ -722,6 +871,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.description = description; } + public String getHookName() { + return EnumScriptType.ACHIEVEMENT.function; + } + public String getDescription() { return description; } @@ -737,6 +890,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.result = NpcAPI.Instance().getIItemStack(result); } + public String getHookName() { + return EnumScriptType.FILL_BUCKET.function; + } + public IItemStack getCurrent() { return current; } @@ -760,6 +917,10 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { this.z = z; } + public String getHookName() { + return EnumScriptType.BONEMEAL.function; + } + public IBlock getBlock() { return block; } @@ -781,5 +942,9 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent { public RangedChargeEvent(IPlayer player) { super(player); } + + public String getHookName() { + return EnumScriptType.RANGED_LAUNCHED.function; + } } } diff --git a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java index 135d9033d..da10624c1 100644 --- a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java @@ -5,6 +5,7 @@ import noppes.npcs.api.event.IQuestEvent; import noppes.npcs.api.handler.data.IQuest; import noppes.npcs.api.item.IItemStack; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.constants.EnumScriptType; public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { public final IQuest quest; @@ -23,10 +24,18 @@ public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { return quest; } + public String getHookName() { + return EnumScriptType.QUEST_EVENT.function; + } + public static class QuestCompletedEvent extends QuestEvent implements IQuestEvent.QuestCompletedEvent { public QuestCompletedEvent(IPlayer player, IQuest quest) { super(player, quest); } + + public String getHookName() { + return EnumScriptType.QUEST_COMPLETED.function; + } } @Cancelable @@ -34,6 +43,10 @@ public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { public QuestStartEvent(IPlayer player, IQuest quest) { super(player, quest); } + + public String getHookName() { + return EnumScriptType.QUEST_START.function; + } } @Cancelable @@ -46,6 +59,10 @@ public class QuestEvent extends CustomNPCsEvent implements IQuestEvent { this.expReward = 0; } + public String getHookName() { + return EnumScriptType.QUEST_TURNIN.function; + } + public void setExpReward(int expReward) { this.expReward = expReward; }