From 5a8246f728f7c258efd41d3ecf2b69edf83b5f3d Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 10 Feb 2025 14:26:22 -0500 Subject: [PATCH] Custom Effects and Player Events API --- java/noppes/npcs/api/event/IPlayerEvent.java | 26 +++++++++ .../api/handler/IStatusEffectHandler.java | 58 +++++++++++++++++++ .../npcs/api/handler/data/ICustomEffect.java | 58 +++++++++++++++++++ .../npcs/api/handler/data/IPlayerEffect.java | 26 +++++++++ 4 files changed, 168 insertions(+) create mode 100644 java/noppes/npcs/api/handler/IStatusEffectHandler.java create mode 100644 java/noppes/npcs/api/handler/data/ICustomEffect.java create mode 100644 java/noppes/npcs/api/handler/data/IPlayerEffect.java diff --git a/java/noppes/npcs/api/event/IPlayerEvent.java b/java/noppes/npcs/api/event/IPlayerEvent.java index 7127c73..7ec624b 100644 --- a/java/noppes/npcs/api/event/IPlayerEvent.java +++ b/java/noppes/npcs/api/event/IPlayerEvent.java @@ -7,6 +7,7 @@ import noppes.npcs.api.IDamageSource; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IEntityLivingBase; import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.api.handler.data.IPlayerEffect; import noppes.npcs.api.item.IItemStack; public interface IPlayerEvent extends ICustomNPCsEvent { @@ -268,4 +269,29 @@ public interface IPlayerEvent extends ICustomNPCsEvent { interface RangedChargeEvent extends IPlayerEvent { } + + interface EffectEvent extends IPlayerEvent { + + IPlayerEffect getEffect(); + + interface Added extends EffectEvent { + + } + interface Ticked extends EffectEvent { + + } + interface Removed extends EffectEvent { + + /** + * @return If the effect timer has ticked down to 0. + */ + boolean hasTimerRunOut(); + + /** + * @return If the effect was removed on death. + */ + boolean causedByDeath(); + } + + } } diff --git a/java/noppes/npcs/api/handler/IStatusEffectHandler.java b/java/noppes/npcs/api/handler/IStatusEffectHandler.java new file mode 100644 index 0000000..df8bdb4 --- /dev/null +++ b/java/noppes/npcs/api/handler/IStatusEffectHandler.java @@ -0,0 +1,58 @@ +package noppes.npcs.api.handler; + +import noppes.npcs.api.entity.IPlayer; +import noppes.npcs.api.handler.data.ICustomEffect; + +public interface IStatusEffectHandler { + + ICustomEffect createEffect(String name); + + ICustomEffect getEffect(String name); + + void deleteEffect(String name); + + /** + * + * @param player Player + * @param id ID of Status Effect -- Only DBC Addon + * @return True if Player has Effect + */ + boolean hasEffect(IPlayer player, int id); + + boolean hasEffect(IPlayer player, ICustomEffect effect); + + /** + * + * -1 : Does not have effect + * -100 : Has infinite effect + * + * @param player Player + * @param id ID of Status Effect -- Only DBC Addon + * @return Effect Time + */ + int getEffectDuration(IPlayer player, int id); + + int getEffectDuration(IPlayer player, ICustomEffect effect); + + /** + * @param player Player + * @param id ID of Status Effect + * @param duration Duration of Effect in Seconds | -100 : Has infinite effect + * @param level Level of Effect [Some effects not affected by level] + */ + void applyEffect(IPlayer player, int id, int duration, byte level); + + void applyEffect(IPlayer player, ICustomEffect effect, int duration, byte level); + + /** + * @param player Player + * @param id ID of Status Effect + */ + void removeEffect(IPlayer player, int id); + + void removeEffect(IPlayer player, ICustomEffect effect); + + void clearEffects(IPlayer player); + + ICustomEffect saveEffect(ICustomEffect customEffect); +} diff --git a/java/noppes/npcs/api/handler/data/ICustomEffect.java b/java/noppes/npcs/api/handler/data/ICustomEffect.java new file mode 100644 index 0000000..ff7a134 --- /dev/null +++ b/java/noppes/npcs/api/handler/data/ICustomEffect.java @@ -0,0 +1,58 @@ +package noppes.npcs.api.handler.data; + +public interface ICustomEffect { + + int getID(); + + String getName(); + + boolean isCustom(); + + void setMenuName(String name); + + String getMenuName(); + + void setName(String name); + + String getIcon(); + + void setIcon(String icon); + + int getEveryXTick(); + + void setEveryXTick(int everyXTick); + + int getIconX(); + + void setIconX(int iconX); + + int getIconY(); + + void setIconY(int iconY); + + int getWidth(); + + void setWidth(int width); + + int getHeight(); + + void setHeight(int height); + + boolean isLossOnDeath(); + + void setLossOnDeath(boolean lossOnDeath); + + ICustomEffect save(); + + void setID(int id); + + /** + * Utilized by DBC Addon or other Addons to tell + * which map of Effects to Match to. + * Index: 0 - CNPC+ + * Index: 1 - DBC Addon + */ + int getIndex(); +} + + diff --git a/java/noppes/npcs/api/handler/data/IPlayerEffect.java b/java/noppes/npcs/api/handler/data/IPlayerEffect.java new file mode 100644 index 0000000..2ea44a2 --- /dev/null +++ b/java/noppes/npcs/api/handler/data/IPlayerEffect.java @@ -0,0 +1,26 @@ +package noppes.npcs.api.handler.data; + +import noppes.npcs.api.entity.IPlayer; + +public interface IPlayerEffect { + + void kill(); + + int getId(); + + int getDuration(); + + void setDuration(int duration); + + byte getLevel(); + + void setLevel(byte level); + + String getName(); + + void performEffect(IPlayer player); + + int getIndex(); + + void setIndex(); +}