mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 22:15:06 +00:00
Implemented event interfaces, made more events cancellable.
This commit is contained in:
1 parent
aa02e5dcc3
commit
0414817673
32 files changed
+1298
-175
No files matched your search
@@ -374,10 +374,10 @@ public class EventHooks {
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) {
|
||||
public static boolean onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) {
|
||||
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
|
||||
handler.callScript(EnumScriptType.FALL, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPlayerJump(PlayerDataScript handler, IPlayer player) {
|
||||
@@ -516,11 +516,9 @@ public class EventHooks {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onCNPCNaturalSpawn(INaturalSpawn naturalSpawn, BlockPos blockPos, boolean animalSpawnPassed, boolean monsterSpawnPassed, boolean liquidSpawnPassed, boolean airSpawnPassed) {
|
||||
public static boolean onCNPCNaturalSpawn(CustomNPCsEvent.CNPCNaturalSpawnEvent event) {
|
||||
ForgeDataScript handler = ScriptController.Instance.forgeScripts;
|
||||
if (handler.isEnabled()) {
|
||||
IPos attemptPosition = NpcAPI.Instance().getIPos(blockPos);
|
||||
CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(naturalSpawn, attemptPosition, animalSpawnPassed, monsterSpawnPassed, liquidSpawnPassed, airSpawnPassed);
|
||||
handler.callScript("onCNPCNaturalSpawn", event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
@@ -577,22 +575,22 @@ public class EventHooks {
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onFactionPoints(FactionEvent.FactionPoints event){
|
||||
public static boolean onFactionPoints(FactionEvent.FactionPoints event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.FACTION_POINTS, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onDialogOpen(DialogEvent.DialogOpen event){
|
||||
public static boolean onDialogOpen(DialogEvent.DialogOpen event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.DIALOG_OPEN, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onDialogOption(DialogEvent.DialogOption event){
|
||||
public static boolean onDialogOption(DialogEvent.DialogOption event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.DIALOG_OPTION, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onDialogClosed(DialogEvent.DialogClosed event){
|
||||
|
||||
@@ -26,6 +26,8 @@ import noppes.npcs.controllers.SpawnController;
|
||||
import noppes.npcs.controllers.data.SpawnData;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.CustomNPCsEvent;
|
||||
|
||||
public class NPCSpawning {
|
||||
private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet();
|
||||
@@ -201,10 +203,12 @@ public class NPCSpawning {
|
||||
if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !canEntitySpawn(data,entityliving)))
|
||||
return false;
|
||||
|
||||
if (EventHooks.onCNPCNaturalSpawn(data, new BlockPos(x,y,z), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn)) {
|
||||
CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(data, NpcAPI.Instance().getIPos(new BlockPos(x,y,z)), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn);
|
||||
if (EventHooks.onCNPCNaturalSpawn(event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
entityliving.setPosition(event.attemptPosition.getX(),event.attemptPosition.getY(),event.attemptPosition.getZ());
|
||||
world.spawnEntityInWorld(entityliving);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -273,8 +273,10 @@ public class NoppesUtilPlayer {
|
||||
if(dialog == null)
|
||||
return;
|
||||
DialogOption option = dialog.options.get(optionId);
|
||||
if (EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)))
|
||||
return;
|
||||
|
||||
if (!npc.isRemote()) {
|
||||
EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
|
||||
EventHooks.onNPCDialogClosed(npc, player, dialogId, optionId + 1, dialog);
|
||||
|
||||
if (!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) {
|
||||
@@ -343,6 +345,8 @@ public class NoppesUtilPlayer {
|
||||
return;
|
||||
|
||||
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
event.expReward = data.quest.rewardExp;
|
||||
|
||||
List<IItemStack> list = new ArrayList();
|
||||
|
||||
@@ -186,7 +186,9 @@ public class NoppesUtilServer {
|
||||
if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) {
|
||||
return;
|
||||
}
|
||||
EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog));
|
||||
if (EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(npc instanceof EntityDialogNpc){
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ScriptItemEventHandler {
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.entityPlayer.worldObj), NpcAPI.Instance().getIPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ)));
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemInteract(isw, eve));
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
|
||||
@@ -319,7 +319,7 @@ public class ScriptPlayerEventHandler {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
|
||||
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
|
||||
event.setCanceled(EventHooks.onPlayerFall(handler, scriptPlayer, event.distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ public class PlayerFactionData implements IPlayerFactionData {
|
||||
}
|
||||
|
||||
public void increasePoints(int factionId, int points, EntityPlayer player) {
|
||||
EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points));
|
||||
if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)))
|
||||
return;
|
||||
|
||||
if(!factionData.containsKey(factionId)){
|
||||
Faction faction = FactionController.getInstance().get(factionId);
|
||||
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
|
||||
|
||||
@@ -2,11 +2,12 @@ package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.api.event.ICustomGuiEvent;
|
||||
import noppes.npcs.api.gui.ICustomGui;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
|
||||
public class CustomGuiEvent extends Event {
|
||||
public class CustomGuiEvent extends Event implements ICustomGuiEvent {
|
||||
public final IPlayer player;
|
||||
public final ICustomGui gui;
|
||||
|
||||
@@ -23,31 +24,43 @@ public class CustomGuiEvent extends Event {
|
||||
return gui;
|
||||
}
|
||||
|
||||
public static class ButtonEvent extends CustomGuiEvent {
|
||||
public int getId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static class ButtonEvent extends CustomGuiEvent implements ICustomGuiEvent.ButtonEvent {
|
||||
public final int buttonId;
|
||||
|
||||
public ButtonEvent(IPlayer player, ICustomGui gui, int buttonId) {
|
||||
super(player, gui);
|
||||
this.buttonId = buttonId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.buttonId;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnfocusedEvent extends CustomGuiEvent {
|
||||
public static class UnfocusedEvent extends CustomGuiEvent implements ICustomGuiEvent.UnfocusedEvent {
|
||||
public final int textfieldId;
|
||||
|
||||
public UnfocusedEvent(IPlayer player, ICustomGui gui, int textfieldId) {
|
||||
super(player, gui);
|
||||
this.textfieldId = textfieldId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.textfieldId;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CloseEvent extends CustomGuiEvent {
|
||||
public static class CloseEvent extends CustomGuiEvent implements ICustomGuiEvent.CloseEvent {
|
||||
public CloseEvent(IPlayer player, ICustomGui gui) {
|
||||
super(player, gui);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ScrollEvent extends CustomGuiEvent {
|
||||
public static class ScrollEvent extends CustomGuiEvent implements ICustomGuiEvent.ScrollEvent {
|
||||
public final int scrollId;
|
||||
public final String[] selection;
|
||||
public final boolean doubleClick;
|
||||
@@ -60,9 +73,25 @@ public class CustomGuiEvent extends Event {
|
||||
this.doubleClick = doubleClick;
|
||||
this.scrollIndex = scrollIndex;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.scrollId;
|
||||
}
|
||||
|
||||
public String[] getSelection() {
|
||||
return selection;
|
||||
}
|
||||
|
||||
public boolean doubleClick() {
|
||||
return doubleClick;
|
||||
}
|
||||
|
||||
public int getScrollIndex() {
|
||||
return scrollIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotEvent extends CustomGuiEvent {
|
||||
public static class SlotEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotEvent {
|
||||
public final int slotId;
|
||||
public final IItemStack stack;
|
||||
|
||||
@@ -71,10 +100,18 @@ public class CustomGuiEvent extends Event {
|
||||
this.slotId = slotId;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.slotId;
|
||||
}
|
||||
|
||||
public IItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class SlotClickEvent extends CustomGuiEvent {
|
||||
public static class SlotClickEvent extends CustomGuiEvent implements ICustomGuiEvent.SlotClickEvent {
|
||||
public final int slotId;
|
||||
public final IItemStack stack;
|
||||
public final int dragType;
|
||||
@@ -90,5 +127,17 @@ public class CustomGuiEvent extends Event {
|
||||
this.dragType = dragType;
|
||||
this.clickType = clickType;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.slotId;
|
||||
}
|
||||
|
||||
public IItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getDragType() {
|
||||
return dragType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,10 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.api.AbstractNpcAPI;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.event.ICustomNPCsEvent;
|
||||
import noppes.npcs.api.handler.data.INaturalSpawn;
|
||||
|
||||
public class CustomNPCsEvent extends Event implements noppes.npcs.api.event.CustomNPCsEvent {
|
||||
public class CustomNPCsEvent extends Event implements ICustomNPCsEvent {
|
||||
public final AbstractNpcAPI API = AbstractNpcAPI.Instance();
|
||||
|
||||
public CustomNPCsEvent() {
|
||||
@@ -24,9 +25,9 @@ public class CustomNPCsEvent extends Event implements noppes.npcs.api.event.Cust
|
||||
public boolean isCancelled(){return this.isCanceled();}
|
||||
|
||||
@Cancelable
|
||||
public static class CNPCNaturalSpawnEvent extends CustomNPCsEvent implements noppes.npcs.api.event.CustomNPCsEvent.CNPCNaturalSpawnEvent {
|
||||
public static class CNPCNaturalSpawnEvent extends CustomNPCsEvent implements ICustomNPCsEvent.CNPCNaturalSpawnEvent {
|
||||
public final INaturalSpawn naturalSpawn;
|
||||
public final IPos attemptPosition;
|
||||
public IPos attemptPosition;
|
||||
public final boolean animalSpawnPassed;
|
||||
public final boolean monsterSpawnPassed;
|
||||
public final boolean liquidSpawnPassed;
|
||||
@@ -46,6 +47,10 @@ public class CustomNPCsEvent extends Event implements noppes.npcs.api.event.Cust
|
||||
return this.naturalSpawn;
|
||||
}
|
||||
|
||||
public void setAttemptPosition(IPos attemptPosition) {
|
||||
this.attemptPosition = attemptPosition;
|
||||
}
|
||||
|
||||
public IPos getAttemptPosition() {
|
||||
return this.attemptPosition;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
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;
|
||||
|
||||
public class DialogEvent extends CustomNPCsEvent {
|
||||
public class DialogEvent extends CustomNPCsEvent implements IDialogEvent {
|
||||
public final IDialog dialog;
|
||||
public final IPlayer player;
|
||||
|
||||
@@ -12,19 +14,29 @@ public class DialogEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static class DialogOpen extends DialogEvent {
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public IDialog getDialog() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DialogOpen extends DialogEvent implements IDialogEvent.DialogOpen {
|
||||
public DialogOpen(IPlayer player, IDialog dialog) {
|
||||
super(player, dialog);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogOption extends DialogEvent {
|
||||
@Cancelable
|
||||
public static class DialogOption extends DialogEvent implements IDialogEvent.DialogOption {
|
||||
public DialogOption(IPlayer player, IDialog dialog) {
|
||||
super(player, dialog);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogClosed extends DialogEvent {
|
||||
public static class DialogClosed extends DialogEvent implements IDialogEvent.DialogClosed {
|
||||
public DialogClosed(IPlayer player, IDialog dialog){
|
||||
super(player, dialog);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
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;
|
||||
|
||||
public class FactionEvent extends CustomNPCsEvent {
|
||||
public class FactionEvent extends CustomNPCsEvent implements IFactionEvent {
|
||||
public final IFaction faction;
|
||||
public final IPlayer player;
|
||||
|
||||
@@ -12,7 +14,16 @@ public class FactionEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static class FactionPoints extends FactionEvent {
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public IFaction getFaction() {
|
||||
return faction;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class FactionPoints extends FactionEvent implements IFactionEvent.FactionPoints {
|
||||
public boolean decrease;
|
||||
public int points;
|
||||
|
||||
@@ -21,5 +32,13 @@ public class FactionEvent extends CustomNPCsEvent {
|
||||
this.decrease = decrease;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public boolean decreased() {
|
||||
return decrease;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return points;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,36 +9,49 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.event.IForgeEvent;
|
||||
|
||||
@Cancelable
|
||||
public class ForgeEvent extends CustomNPCsEvent {
|
||||
public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent {
|
||||
public final Event event;
|
||||
|
||||
public ForgeEvent(Event event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public Event getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class WorldEvent extends ForgeEvent {
|
||||
public static class WorldEvent extends ForgeEvent implements IForgeEvent.WorldEvent {
|
||||
public final IWorld world;
|
||||
|
||||
public WorldEvent(net.minecraftforge.event.world.WorldEvent event, IWorld world) {
|
||||
super(event);
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public IWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class EntityEvent extends ForgeEvent {
|
||||
public static class EntityEvent extends ForgeEvent implements IForgeEvent.EntityEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public EntityEvent(net.minecraftforge.event.entity.EntityEvent event, IEntity entity) {
|
||||
super(event);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitEvent extends ForgeEvent {
|
||||
public static class InitEvent extends ForgeEvent implements IForgeEvent.InitEvent {
|
||||
public InitEvent() {
|
||||
super((Event)null);
|
||||
}
|
||||
|
||||
@@ -1,91 +1,141 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.api.event.IItemEvent;
|
||||
import noppes.npcs.api.item.IItemCustom;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
|
||||
public class ItemEvent extends CustomNPCsEvent {
|
||||
public IItemCustom item;
|
||||
public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
|
||||
public final IItemCustom item;
|
||||
|
||||
public ItemEvent(IItemCustom item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public static class InitEvent extends ItemEvent {
|
||||
public IItemCustom getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public static class InitEvent extends ItemEvent implements IItemEvent.InitEvent {
|
||||
public InitEvent(IItemCustom item) {
|
||||
super(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
public static class UpdateEvent extends ItemEvent implements IItemEvent.UpdateEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public UpdateEvent(IItemCustom item, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TossedEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
public IPlayer player;
|
||||
public static class TossedEvent extends ItemEvent implements IItemEvent.TossedEvent {
|
||||
public final IEntity entity;
|
||||
public final IPlayer player;
|
||||
|
||||
public TossedEvent(IItemCustom item, IPlayer player, IEntity entity) {
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PickedUpEvent extends ItemEvent {
|
||||
public IPlayer player;
|
||||
public static class PickedUpEvent extends ItemEvent implements IItemEvent.PickedUpEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
public PickedUpEvent(IItemCustom item, IPlayer player) {
|
||||
super(item);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class SpawnEvent extends ItemEvent {
|
||||
public IEntity entity;
|
||||
public SpawnEvent(IItemCustom item, IEntity entity){
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends ItemEvent {
|
||||
public final int type;
|
||||
public final Object target;
|
||||
public IPlayer player;
|
||||
public static class SpawnEvent extends ItemEvent implements IItemEvent.SpawnEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public InteractEvent(IItemCustom item, IPlayer player, int type, Object target) {
|
||||
public SpawnEvent(IItemCustom item, IEntity entity){
|
||||
super(item);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends ItemEvent implements IItemEvent.InteractEvent {
|
||||
public final int type;
|
||||
public final IEntity target;
|
||||
public final IPlayer player;
|
||||
|
||||
public InteractEvent(IItemCustom item, IPlayer player, int type, IEntity target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public IEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends ItemEvent {
|
||||
public static class AttackEvent extends ItemEvent implements IItemEvent.AttackEvent {
|
||||
public final int type;//1: Hit, 2: Whiff
|
||||
public final Object target;
|
||||
public IEntity swingingEntity;
|
||||
public final IEntity target;
|
||||
public final IEntity swingingEntity;
|
||||
|
||||
public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, Object target) {
|
||||
public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, IEntity target) {
|
||||
super(item);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.swingingEntity = swingingEntity;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public IEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public IEntity getSwingingEntity() {
|
||||
return swingingEntity;
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartUsingItem extends ItemEvent {
|
||||
public static class StartUsingItem extends ItemEvent implements IItemEvent.StartUsingItem {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
@@ -94,8 +144,16 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class UsingItem extends ItemEvent {
|
||||
public static class UsingItem extends ItemEvent implements IItemEvent.UsingItem {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
@@ -104,8 +162,16 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class StopUsingItem extends ItemEvent {
|
||||
public static class StopUsingItem extends ItemEvent implements IItemEvent.StopUsingItem {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
@@ -114,8 +180,16 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class FinishUsingItem extends ItemEvent {
|
||||
public static class FinishUsingItem extends ItemEvent implements IItemEvent.FinishUsingItem {
|
||||
public final IPlayer player;
|
||||
public final int duration;
|
||||
|
||||
@@ -124,5 +198,13 @@ public class ItemEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.controllers.data.Dialog;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
@@ -22,14 +24,18 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NpcEvent extends CustomNPCsEvent {
|
||||
public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
|
||||
public final ICustomNpc npc;
|
||||
|
||||
public NpcEvent(ICustomNpc npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public static class TimerEvent extends NpcEvent {
|
||||
public ICustomNpc getNpc() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public static class TimerEvent extends NpcEvent implements INpcEvent.TimerEvent {
|
||||
public final int id;
|
||||
|
||||
public TimerEvent(ICustomNpc npc, int id) {
|
||||
@@ -42,17 +48,21 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CollideEvent extends NpcEvent {
|
||||
public static class CollideEvent extends NpcEvent implements INpcEvent.CollideEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public CollideEvent(ICustomNpc npc, Entity entity) {
|
||||
super(npc);
|
||||
this.entity = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEvent extends NpcEvent {
|
||||
public static class DamagedEvent extends NpcEvent implements INpcEvent.DamagedEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity source;
|
||||
public float damage;
|
||||
@@ -78,6 +88,10 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
return source;
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource(){
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
@@ -107,7 +121,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class RangedLaunchedEvent extends NpcEvent {
|
||||
public static class RangedLaunchedEvent extends NpcEvent implements INpcEvent.RangedLaunchedEvent {
|
||||
public final IEntityLivingBase target;
|
||||
public float damage;
|
||||
//public List<IProjectile> projectiles = new ArrayList();
|
||||
@@ -126,6 +140,13 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
@@ -134,13 +155,6 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
@@ -150,7 +164,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class MeleeAttackEvent extends NpcEvent {
|
||||
public static class MeleeAttackEvent extends NpcEvent implements INpcEvent.MeleeAttackEvent {
|
||||
public final IEntityLivingBase target;
|
||||
public float damage;
|
||||
|
||||
@@ -191,17 +205,21 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static class KilledEntityEvent extends NpcEvent {
|
||||
public static class KilledEntityEvent extends NpcEvent implements INpcEvent.KilledEntityEvent {
|
||||
public final IEntityLivingBase entity;
|
||||
|
||||
public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntityLivingBase getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DiedEvent extends NpcEvent {
|
||||
public static class DiedEvent extends NpcEvent implements INpcEvent.DiedEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final String type;
|
||||
public final IEntity source;
|
||||
@@ -238,24 +256,44 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
public String getType(){
|
||||
return damageSource.getMCDamageSource().damageType;
|
||||
}
|
||||
|
||||
public void setDroppedItems(IItemStack[] droppedItems) {
|
||||
this.droppedItems = droppedItems;
|
||||
}
|
||||
|
||||
public IItemStack[] getDroppedItems() {
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
public void setExpDropped(int expDropped) {
|
||||
this.expDropped = expDropped;
|
||||
}
|
||||
|
||||
public int getExpDropped() {
|
||||
return expDropped;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends NpcEvent {
|
||||
public static class InteractEvent extends NpcEvent implements INpcEvent.InteractEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
public InteractEvent(ICustomNpc npc, EntityPlayer player) {
|
||||
super(npc);
|
||||
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DialogEvent extends NpcEvent {
|
||||
public static class DialogEvent extends NpcEvent implements INpcEvent.DialogEvent {
|
||||
public final IPlayer player;
|
||||
public final int id;
|
||||
public final int optionId;
|
||||
public final Dialog dialogObj;
|
||||
public final IDialog dialogObj;
|
||||
|
||||
public final int dialog;
|
||||
public final int option;
|
||||
@@ -275,7 +313,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Dialog getDialog() {
|
||||
public IDialog getDialog() {
|
||||
return dialogObj;
|
||||
}
|
||||
|
||||
@@ -295,7 +333,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogClosedEvent extends NpcEvent {
|
||||
public static class DialogClosedEvent extends NpcEvent implements INpcEvent.DialogClosedEvent {
|
||||
public final IPlayer player;
|
||||
public final int id;
|
||||
public final int optionId;
|
||||
@@ -340,17 +378,21 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TargetLostEvent extends NpcEvent {
|
||||
public static class TargetLostEvent extends NpcEvent implements INpcEvent.TargetLostEvent {
|
||||
public final IEntityLivingBase entity;
|
||||
|
||||
public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntityLivingBase getTarget() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TargetEvent extends NpcEvent {
|
||||
public static class TargetEvent extends NpcEvent implements INpcEvent.TargetEvent {
|
||||
public IEntityLivingBase entity;
|
||||
|
||||
public TargetEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
@@ -358,25 +400,25 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public void setTarget(IEntityLivingBase entity){
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The target source
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setTarget(IEntityLivingBase entity){
|
||||
this.entity = entity;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateEvent extends NpcEvent {
|
||||
public static class UpdateEvent extends NpcEvent implements INpcEvent.UpdateEvent {
|
||||
public UpdateEvent(ICustomNpc npc) {
|
||||
super(npc);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitEvent extends NpcEvent {
|
||||
public static class InitEvent extends NpcEvent implements INpcEvent.InitEvent {
|
||||
public InitEvent(ICustomNpc npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@@ -18,27 +18,40 @@ 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.event.IPlayerEvent;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class PlayerEvent extends CustomNPCsEvent {
|
||||
public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
public PlayerEvent(IPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ChatEvent extends PlayerEvent {
|
||||
public static class ChatEvent extends PlayerEvent implements IPlayerEvent.ChatEvent {
|
||||
public String message;
|
||||
|
||||
public ChatEvent(IPlayer player, String message) {
|
||||
super(player);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyPressedEvent extends PlayerEvent {
|
||||
public static class KeyPressedEvent extends PlayerEvent implements IPlayerEvent.KeyPressedEvent {
|
||||
public final int key;
|
||||
public final boolean isCtrlPressed;
|
||||
public final boolean isAltPressed;
|
||||
@@ -57,9 +70,37 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.keyDown = keyDown;
|
||||
this.keysDown = heldKeys;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean isCtrlPressed() {
|
||||
return isCtrlPressed;
|
||||
}
|
||||
|
||||
public boolean isAltPressed() {
|
||||
return isAltPressed;
|
||||
}
|
||||
|
||||
public boolean isShiftPressed() {
|
||||
return isShiftPressed;
|
||||
}
|
||||
|
||||
public boolean isMetaPressed() {
|
||||
return isMetaPressed;
|
||||
}
|
||||
|
||||
public boolean keyDown() {
|
||||
return keyDown;
|
||||
}
|
||||
|
||||
public int[] getKeysDown() {
|
||||
return keysDown;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MouseClickedEvent extends PlayerEvent {
|
||||
public static class MouseClickedEvent extends PlayerEvent implements IPlayerEvent.MouseClickedEvent {
|
||||
public final boolean isCtrlPressed;
|
||||
public final boolean isAltPressed;
|
||||
public final boolean isShiftPressed;
|
||||
@@ -81,45 +122,85 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.isMetaPressed = isMetaPressed;
|
||||
this.keysDown = heldKeys;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
public int getMouseWheel() {
|
||||
return mouseWheel;
|
||||
}
|
||||
|
||||
public boolean buttonDown() {
|
||||
return buttonDown;
|
||||
}
|
||||
|
||||
public boolean isCtrlPressed() {
|
||||
return isCtrlPressed;
|
||||
}
|
||||
|
||||
public boolean isAltPressed() {
|
||||
return isAltPressed;
|
||||
}
|
||||
|
||||
public boolean isShiftPressed() {
|
||||
return isShiftPressed;
|
||||
}
|
||||
|
||||
public boolean isMetaPressed() {
|
||||
return isMetaPressed;
|
||||
}
|
||||
|
||||
public int[] getKeysDown() {
|
||||
return keysDown;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PickupXPEvent extends PlayerEvent {
|
||||
public static class PickupXPEvent extends PlayerEvent implements IPlayerEvent.PickupXPEvent {
|
||||
public final int amount;
|
||||
|
||||
public PickupXPEvent(IPlayer player, EntityXPOrb orb) {
|
||||
super(player);
|
||||
this.amount = orb.xpValue;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LevelUpEvent extends PlayerEvent {
|
||||
public static class LevelUpEvent extends PlayerEvent implements IPlayerEvent.LevelUpEvent {
|
||||
public final int change;
|
||||
|
||||
public LevelUpEvent(IPlayer player, int change) {
|
||||
super(player);
|
||||
this.change = change;
|
||||
}
|
||||
|
||||
public int getChange() {
|
||||
return change;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogoutEvent extends PlayerEvent {
|
||||
public static class LogoutEvent extends PlayerEvent implements IPlayerEvent.LogoutEvent {
|
||||
public LogoutEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoginEvent extends PlayerEvent {
|
||||
public static class LoginEvent extends PlayerEvent implements IPlayerEvent.LoginEvent {
|
||||
public LoginEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RespawnEvent extends PlayerEvent {
|
||||
public static class RespawnEvent extends PlayerEvent implements IPlayerEvent.RespawnEvent {
|
||||
public RespawnEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangedDimension extends PlayerEvent {
|
||||
public static class ChangedDimension extends PlayerEvent implements IPlayerEvent.ChangedDimension {
|
||||
public final int fromDim;
|
||||
public final int toDim;
|
||||
|
||||
@@ -128,19 +209,31 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.fromDim = fromDim;
|
||||
this.toDim = toDim;
|
||||
}
|
||||
|
||||
public int getFromDim() {
|
||||
return fromDim;
|
||||
}
|
||||
|
||||
public int getToDim() {
|
||||
return toDim;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TimerEvent extends PlayerEvent {
|
||||
public static class TimerEvent extends PlayerEvent implements IPlayerEvent.TimerEvent {
|
||||
public final int id;
|
||||
|
||||
public TimerEvent(IPlayer player, int id) {
|
||||
super(player);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackedEvent extends PlayerEvent {
|
||||
public static class AttackedEvent extends PlayerEvent implements IPlayerEvent.AttackedEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity source;
|
||||
public final float damage;
|
||||
@@ -151,10 +244,22 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public IEntity getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEvent extends PlayerEvent {
|
||||
public static class DamagedEvent extends PlayerEvent implements IPlayerEvent.DamagedEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity source;
|
||||
public float damage;
|
||||
@@ -166,17 +271,29 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public IEntity getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class LightningEvent extends PlayerEvent {
|
||||
public static class LightningEvent extends PlayerEvent implements IPlayerEvent.LightningEvent {
|
||||
public LightningEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class SoundEvent extends PlayerEvent {
|
||||
public static class SoundEvent extends PlayerEvent implements IPlayerEvent.SoundEvent {
|
||||
public final String name;
|
||||
public final float pitch;
|
||||
public final float volume;
|
||||
@@ -187,34 +304,54 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.pitch = pitch;
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public float getVolume() {
|
||||
return volume;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FallEvent extends PlayerEvent {
|
||||
@Cancelable
|
||||
public static class FallEvent extends PlayerEvent implements IPlayerEvent.FallEvent {
|
||||
public final float distance;
|
||||
|
||||
public FallEvent(IPlayer player, float distance){
|
||||
super(player);
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public float getDistance() {
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JumpEvent extends PlayerEvent {
|
||||
public static class JumpEvent extends PlayerEvent implements IPlayerEvent.JumpEvent {
|
||||
public JumpEvent(IPlayer player){
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class KilledEntityEvent extends PlayerEvent {
|
||||
public static class KilledEntityEvent extends PlayerEvent implements IPlayerEvent.KilledEntityEvent {
|
||||
public final IEntityLivingBase entity;
|
||||
|
||||
public KilledEntityEvent(IPlayer player, EntityLivingBase entity) {
|
||||
super(player);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntityLivingBase getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DiedEvent extends PlayerEvent {
|
||||
public static class DiedEvent extends PlayerEvent implements IPlayerEvent.DiedEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final String type;
|
||||
public final IEntity source;
|
||||
@@ -225,10 +362,22 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.type = damagesource.getDamageType();
|
||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public IEntity getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class RangedLaunchedEvent extends PlayerEvent {
|
||||
public static class RangedLaunchedEvent extends PlayerEvent implements IPlayerEvent.RangedLaunchedEvent {
|
||||
public final IItemStack bow;
|
||||
public int charge;
|
||||
|
||||
@@ -237,10 +386,18 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.bow = NpcAPI.Instance().getIItemStack(bow);
|
||||
this.charge = charge;
|
||||
}
|
||||
|
||||
public IItemStack getBow() {
|
||||
return bow;
|
||||
}
|
||||
|
||||
public int getCharge() {
|
||||
return charge;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends PlayerEvent {
|
||||
public static class AttackEvent extends PlayerEvent implements IPlayerEvent.AttackEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity target;
|
||||
public float damage;
|
||||
@@ -251,10 +408,22 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public IEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEntityEvent extends PlayerEvent {
|
||||
public static class DamagedEntityEvent extends PlayerEvent implements IPlayerEvent.DamagedEntityEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity target;
|
||||
public float damage;
|
||||
@@ -265,81 +434,121 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() {
|
||||
return damageSource;
|
||||
}
|
||||
|
||||
public IEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContainerClosed extends PlayerEvent {
|
||||
public static class ContainerClosed extends PlayerEvent implements IPlayerEvent.ContainerClosed {
|
||||
public final IContainer container;
|
||||
|
||||
public ContainerClosed(IPlayer player, IContainer container) {
|
||||
super(player);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public IContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContainerOpen extends PlayerEvent {
|
||||
public static class ContainerOpen extends PlayerEvent implements IPlayerEvent.ContainerOpen {
|
||||
public final IContainer container;
|
||||
|
||||
public ContainerOpen(IPlayer player, IContainer container) {
|
||||
super(player);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public IContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PickUpEvent extends PlayerEvent {
|
||||
public static class PickUpEvent extends PlayerEvent implements IPlayerEvent.PickUpEvent {
|
||||
public final IItemStack item;
|
||||
|
||||
public PickUpEvent(IPlayer player, IItemStack item) {
|
||||
super(player);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DropEvent extends PlayerEvent {
|
||||
public static class DropEvent extends PlayerEvent implements IPlayerEvent.DropEvent {
|
||||
public final IItemStack[] items;
|
||||
|
||||
public DropEvent(IPlayer player, IItemStack[] items) {
|
||||
super(player);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public IItemStack[] getItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TossEvent extends PlayerEvent {
|
||||
public static class TossEvent extends PlayerEvent implements IPlayerEvent.TossEvent {
|
||||
public final IItemStack item;
|
||||
|
||||
public TossEvent(IPlayer player, IItemStack item) {
|
||||
super(player);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends PlayerEvent {
|
||||
public static class InteractEvent extends PlayerEvent implements IPlayerEvent.InteractEvent {
|
||||
public final int type;
|
||||
public final Object target;
|
||||
public final IEntity target;
|
||||
|
||||
public InteractEvent(IPlayer player, int type, Object target) {
|
||||
public InteractEvent(IPlayer player, int type, IEntity target) {
|
||||
super(player);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public IEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateEvent extends PlayerEvent {
|
||||
public static class UpdateEvent extends PlayerEvent implements IPlayerEvent.UpdateEvent {
|
||||
public UpdateEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitEvent extends PlayerEvent {
|
||||
public static class InitEvent extends PlayerEvent implements IPlayerEvent.InitEvent {
|
||||
public InitEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartUsingItem extends PlayerEvent {
|
||||
public static class StartUsingItem extends PlayerEvent implements IPlayerEvent.StartUsingItem {
|
||||
public final IItemStack item;
|
||||
public final int duration;
|
||||
|
||||
@@ -349,8 +558,16 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.item = NpcAPI.Instance().getIItemStack(item);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class UsingItem extends PlayerEvent {
|
||||
public static class UsingItem extends PlayerEvent implements IPlayerEvent.UsingItem {
|
||||
public final IItemStack item;
|
||||
public final int duration;
|
||||
|
||||
@@ -360,8 +577,16 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.item = NpcAPI.Instance().getIItemStack(item);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class StopUsingItem extends PlayerEvent {
|
||||
public static class StopUsingItem extends PlayerEvent implements IPlayerEvent.StopUsingItem {
|
||||
public final IItemStack item;
|
||||
public final int duration;
|
||||
|
||||
@@ -371,8 +596,16 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.item = NpcAPI.Instance().getIItemStack(item);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
public static class FinishUsingItem extends PlayerEvent {
|
||||
public static class FinishUsingItem extends PlayerEvent implements IPlayerEvent.FinishUsingItem {
|
||||
public final IItemStack item;
|
||||
public final int duration;
|
||||
|
||||
@@ -382,10 +615,18 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.item = NpcAPI.Instance().getIItemStack(item);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public IItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class BreakEvent extends PlayerEvent {
|
||||
public static class BreakEvent extends PlayerEvent implements IPlayerEvent.BreakEvent {
|
||||
public final IBlock block;
|
||||
public int exp;
|
||||
|
||||
@@ -394,9 +635,17 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.block = block;
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
public IBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return exp;
|
||||
}
|
||||
}
|
||||
|
||||
public static class UseHoe extends PlayerEvent {
|
||||
public static class UseHoe extends PlayerEvent implements UseHoeEvent {
|
||||
public final IItemStack hoe;
|
||||
public final int x;
|
||||
public final int y;
|
||||
@@ -409,18 +658,38 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public IItemStack getHoe() {
|
||||
return hoe;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WakeUp extends PlayerEvent{
|
||||
public static class WakeUp extends PlayerEvent implements WakeUpEvent {
|
||||
public final boolean setSpawn;
|
||||
|
||||
public WakeUp(IPlayer player, boolean setSpawn) {
|
||||
super(player);
|
||||
this.setSpawn = setSpawn;
|
||||
}
|
||||
|
||||
public boolean setSpawn() {
|
||||
return setSpawn;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Sleep extends PlayerEvent {
|
||||
public static class Sleep extends PlayerEvent implements SleepEvent {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
@@ -431,18 +700,34 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Achievement extends PlayerEvent {
|
||||
public static class Achievement extends PlayerEvent implements AchievementEvent {
|
||||
public final String description;
|
||||
|
||||
public Achievement(IPlayer player, String description) {
|
||||
super(player);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FillBucket extends PlayerEvent {
|
||||
public static class FillBucket extends PlayerEvent implements FillBucketEvent {
|
||||
public final IItemStack current;
|
||||
public final IItemStack result;
|
||||
|
||||
@@ -451,9 +736,17 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.current = NpcAPI.Instance().getIItemStack(current);
|
||||
this.result = NpcAPI.Instance().getIItemStack(result);
|
||||
}
|
||||
|
||||
public IItemStack getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public IItemStack getFilled() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Bonemeal extends PlayerEvent {
|
||||
public static class Bonemeal extends PlayerEvent implements BonemealEvent {
|
||||
public final IBlock block;
|
||||
public final int x;
|
||||
public final int y;
|
||||
@@ -466,9 +759,25 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public IBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RangedChargeEvent extends PlayerEvent {
|
||||
public static class RangedChargeEvent extends PlayerEvent implements IPlayerEvent.RangedChargeEvent {
|
||||
public RangedChargeEvent(IPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
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;
|
||||
|
||||
public class QuestEvent extends CustomNPCsEvent {
|
||||
public class QuestEvent extends CustomNPCsEvent implements IQuestEvent {
|
||||
public final IQuest quest;
|
||||
public final IPlayer player;
|
||||
|
||||
@@ -14,20 +15,29 @@ public class QuestEvent extends CustomNPCsEvent {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static class QuestCompletedEvent extends QuestEvent {
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public IQuest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
|
||||
public static class QuestCompletedEvent extends QuestEvent implements IQuestEvent.QuestCompletedEvent {
|
||||
public QuestCompletedEvent(IPlayer player, IQuest quest) {
|
||||
super(player, quest);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class QuestStartEvent extends QuestEvent {
|
||||
public static class QuestStartEvent extends QuestEvent implements IQuestEvent.QuestStartEvent {
|
||||
public QuestStartEvent(IPlayer player, IQuest quest) {
|
||||
super(player, quest);
|
||||
}
|
||||
}
|
||||
|
||||
public static class QuestTurnedInEvent extends QuestEvent {
|
||||
@Cancelable
|
||||
public static class QuestTurnedInEvent extends QuestEvent implements IQuestEvent.QuestTurnedInEvent {
|
||||
public int expReward;
|
||||
public IItemStack[] itemRewards = new IItemStack[0];
|
||||
|
||||
@@ -35,6 +45,22 @@ public class QuestEvent extends CustomNPCsEvent {
|
||||
super(player, quest);
|
||||
this.expReward = 0;
|
||||
}
|
||||
|
||||
public void setExpReward(int expReward) {
|
||||
this.expReward = expReward;
|
||||
}
|
||||
|
||||
public void setItemRewards(IItemStack[] itemRewards) {
|
||||
this.itemRewards = itemRewards;
|
||||
}
|
||||
|
||||
public int getExpReward() {
|
||||
return expReward;
|
||||
}
|
||||
|
||||
public IItemStack[] getItemRewards() {
|
||||
return itemRewards;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user