mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 10:49:07 +00:00
Profile Events
This commit is contained in:
1 parent
b64481dec1
commit
67a1650fb6
4 files changed
+100
-5
No files matched your search
@@ -17,10 +17,12 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.*;
|
||||
import noppes.npcs.api.event.IAnimationEvent;
|
||||
import noppes.npcs.api.event.IPlayerEvent;
|
||||
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.handler.data.IProfile;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
import noppes.npcs.api.item.IItemLinked;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
@@ -917,4 +919,22 @@ public class EventHooks {
|
||||
}
|
||||
postAnimationEvent(new AnimationEvent.FrameEvent.Exited(animation, frame));
|
||||
}
|
||||
|
||||
public static boolean onProfileChange(PlayerDataScript handler, IPlayer player, IProfile profile, int slot) {
|
||||
PlayerEvent.ProfileEvent.Changed event = new PlayerEvent.ProfileEvent.Changed(player, profile, slot, profile.getCurrentSlotId());
|
||||
handler.callScript(EnumScriptType.PROFILE_CHANGE, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onProfileRemove(PlayerDataScript handler, IPlayer player, IProfile profile, int slot) {
|
||||
PlayerEvent.ProfileEvent.Removed event = new PlayerEvent.ProfileEvent.Removed(player, profile, slot);
|
||||
handler.callScript(EnumScriptType.PROFILE_REMOVE, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onProfileCreate(PlayerDataScript handler, IPlayer player, IProfile profile, int slot) {
|
||||
PlayerEvent.ProfileEvent.Create event = new PlayerEvent.ProfileEvent.Create(player, profile, slot);
|
||||
handler.callScript(EnumScriptType.PROFILE_CREATE, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,12 @@ public enum EnumScriptType {
|
||||
ANIMATION_FRAME_EXIT("frameExit"),
|
||||
|
||||
LINKED_ITEM_VERSION("versionChanged"),
|
||||
LINKED_ITEM_BUILD("buildingItem");
|
||||
LINKED_ITEM_BUILD("buildingItem"),
|
||||
|
||||
PROFILE("profile"),
|
||||
PROFILE_CHANGE("profileChange"),
|
||||
PROFILE_REMOVE("profileRemove"),
|
||||
PROFILE_CREATE("profileCreate");
|
||||
|
||||
public String function;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.event.IPlayerEvent;
|
||||
import noppes.npcs.api.handler.data.IPlayerEffect;
|
||||
import noppes.npcs.api.handler.data.IProfile;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
@@ -1005,4 +1006,73 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
||||
DEATH
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ProfileEvent extends PlayerEvent implements IPlayerEvent.ProfileEvent {
|
||||
public final IProfile profile;
|
||||
public final int slot;
|
||||
|
||||
public ProfileEvent(IPlayer player, IProfile profile, int slot) {
|
||||
super(player);
|
||||
this.profile = profile;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfile getProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Changed extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Changed {
|
||||
public final int prevSlot;
|
||||
|
||||
public Changed(IPlayer player, IProfile profile, int slot, int prevSlot) {
|
||||
super(player, profile, slot);
|
||||
this.prevSlot = prevSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevSlot() {
|
||||
return this.prevSlot;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_CHANGE.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Removed extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Removed {
|
||||
|
||||
public Removed(IPlayer player, IProfile profile, int slot) {
|
||||
super(player, profile, slot);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_REMOVE.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Create extends PlayerEvent.ProfileEvent implements IPlayerEvent.ProfileEvent.Create {
|
||||
|
||||
public Create(IPlayer player, IProfile profile, int slot) {
|
||||
super(player, profile, slot);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PROFILE_CREATE.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user