diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index a14226b80..9b13a1ff2 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -1,6 +1,5 @@ package noppes.npcs; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -27,7 +26,8 @@ import noppes.npcs.controllers.*; import noppes.npcs.enchants.EnchantInterface; import noppes.npcs.entity.*; import noppes.npcs.entity.old.*; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; + import java.io.File; import java.util.Set; @@ -257,7 +257,7 @@ public class CustomNpcs { ScriptController.Instance.loadNPCScripts(); ScriptController.Instance.loadPlayerScripts(); ScriptController.HasStart = false; - WrapperNpcAPI.clearCache(); + NpcAPI.clearCache(); Set names = Block.blockRegistry.getKeys(); for(String name : names){ diff --git a/src/main/java/noppes/npcs/DataScript.java b/src/main/java/noppes/npcs/DataScript.java index 8e8c70cc3..eb85f950b 100644 --- a/src/main/java/noppes/npcs/DataScript.java +++ b/src/main/java/noppes/npcs/DataScript.java @@ -15,7 +15,6 @@ import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ScriptEvent; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.ScriptWorld; @@ -24,7 +23,7 @@ import noppes.npcs.scripted.constants.JobType; import noppes.npcs.scripted.constants.RoleType; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; public class DataScript implements IScriptHandler { public List scripts = new ArrayList(); @@ -134,7 +133,7 @@ public class DataScript implements IScriptHandler { ScriptEvent result = (ScriptEvent) engine.get("event"); if(result == null) engine.put("event", result = new ScriptEvent()); - engine.put("API", new WrapperNpcAPI()); + engine.put("API", new NpcAPI()); engine.put("EntityType", entities); engine.put("RoleType", roles); engine.put("JobType", jobs); diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 407b33acb..4bb574437 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -41,7 +41,7 @@ import noppes.npcs.scripted.interfaces.gui.ICustomGui; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.constants.EnumScriptType; import org.apache.commons.lang3.StringUtils; @@ -55,7 +55,7 @@ public class EventHooks { if (!handler.isClient()) { ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler); handler.callScript(EnumScriptType.INIT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } @@ -63,60 +63,60 @@ public class EventHooks { if (!handler.isClient()) { ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, ScriptController.Instance.getScriptForEntity(player)); handler.callScript(EnumScriptType.TICK, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) { ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.TOSSED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemPickedUp(ScriptCustomItem handler, EntityPlayer player) { ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); handler.callScript(EnumScriptType.PICKEDUP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) { ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.SPAWN, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemInteract(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemAttack(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) { handler.callScript(EnumScriptType.ATTACK, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStartUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration); handler.callScript(EnumScriptType.USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStopUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onFinishUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onNPCInit(EntityNPCInterface npc) { @@ -126,7 +126,7 @@ public class EventHooks { noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event); npc.script.callScript(EnumScriptType.INIT); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCUpdate(EntityNPCInterface npc) { @@ -136,7 +136,7 @@ public class EventHooks { noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event); npc.script.callScript(EnumScriptType.TICK); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { @@ -149,7 +149,7 @@ public class EventHooks { ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog); npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog()); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { @@ -162,7 +162,7 @@ public class EventHooks { ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog); npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog()); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) { @@ -172,7 +172,7 @@ public class EventHooks { NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event); boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -183,7 +183,7 @@ public class EventHooks { NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -194,7 +194,7 @@ public class EventHooks { NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -205,7 +205,7 @@ public class EventHooks { NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event); npc.script.callScript(EnumScriptType.KILLS, "target", entity); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){ @@ -215,7 +215,7 @@ public class EventHooks { NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event); boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target)); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -226,7 +226,7 @@ public class EventHooks { NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event); npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){ @@ -236,7 +236,7 @@ public class EventHooks { NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource); ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event); boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -247,7 +247,7 @@ public class EventHooks { NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event); boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -259,48 +259,48 @@ public class EventHooks { ScriptEventTimer scriptEvent = new ScriptEventTimer(id); npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) { noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player); handler.callScript(EnumScriptType.INIT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) { noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player); handler.callScript(EnumScriptType.TICK, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration); handler.callScript(EnumScriptType.USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList entityItems) { @@ -309,178 +309,178 @@ public class EventHooks { DropEvent event = new DropEvent(player, items); handler.callScript(EnumScriptType.DROP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) { PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb); handler.callScript(EnumScriptType.PICKUP_XP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.TOSS, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.PICKUP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) { ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container)); handler.callScript(EnumScriptType.CONTAINER_OPEN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z); handler.callScript(EnumScriptType.USE_HOE, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z); handler.callScript(EnumScriptType.SLEEP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) { noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn); handler.callScript(EnumScriptType.WAKE_UP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) { noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity); handler.callScript(EnumScriptType.KILLED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) { noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving); handler.callScript(EnumScriptType.KILLS, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) { handler.callScript(EnumScriptType.DAMAGED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player); handler.callScript(EnumScriptType.LIGHTNING, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) { PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume); handler.callScript(EnumScriptType.PLAYSOUND, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) { PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance); handler.callScript(EnumScriptType.FALL, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player); handler.callScript(EnumScriptType.JUMP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) { LoginEvent event = new LoginEvent(player); handler.callScript(EnumScriptType.LOGIN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) { PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description); handler.callScript(EnumScriptType.ACHIEVEMENT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) { PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result); handler.callScript(EnumScriptType.FILL_BUCKET, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) { PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world); handler.callScript(EnumScriptType.BONEMEAL, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player); handler.callScript(EnumScriptType.RESPAWN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) { LogoutEvent event = new LogoutEvent(player); handler.callScript(EnumScriptType.LOGOUT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) { handler.callScript(EnumScriptType.CHAT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) { handler.callScript(EnumScriptType.RANGED_CHARGE, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) { handler.callScript(EnumScriptType.RANGED_LAUNCHED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) { handler.callScript(EnumScriptType.DAMAGED_ENTITY, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) { PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim); handler.callScript(EnumScriptType.CHANGED_DIM, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) { PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown); handler.callScript(EnumScriptType.MOUSE_CLICKED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTimer(PlayerData data, int id) { PlayerDataScript handler = ScriptController.Instance.playerScripts; noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id); handler.callScript(EnumScriptType.TIMER, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) { handler.callScript(EnumScriptType.BREAK_BLOCK, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onForgeEntityEvent(EntityEvent event) { @@ -498,7 +498,7 @@ public class EventHooks { public static void onForgeInit(ForgeDataScript handler) { noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent(); handler.callScript("init", event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onForgeEvent(ForgeEvent ev, Event event) { @@ -512,7 +512,7 @@ public class EventHooks { } handler.callScript(eventName, event); - WrapperNpcAPI.EVENT_BUS.post(ev); + NpcAPI.EVENT_BUS.post(ev); if(event.isCancelable()) { event.setCanceled(ev.isCanceled()); } @@ -549,43 +549,43 @@ public class EventHooks { PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_COMPLETED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onQuestStarted(EntityPlayer player, Quest quest){ PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_START, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.QUEST_TURNIN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onFactionPoints(FactionEvent.FactionPoints event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.FACTION_POINTS, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogOpen(DialogEvent.DialogOpen event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPEN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogOption(DialogEvent.DialogOption event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPTION, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogClosed(DialogEvent.DialogClosed event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_CLOSE, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } \ No newline at end of file diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 6e5101f6e..eb5066ecd 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -29,11 +29,11 @@ import noppes.npcs.controllers.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.QuestEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class NoppesUtilPlayer { diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index d0bb72d25..18892ed2c 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -51,7 +51,6 @@ import noppes.npcs.roles.RoleTrader; import noppes.npcs.roles.RoleTransporter; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.item.ScriptCustomItem; diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index 23d56811a..c460cb80c 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -15,12 +15,13 @@ import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.items.ItemScripted; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.wrapper.NpcAPI; + import java.util.HashMap; public class ScriptItemEventHandler { diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index d2a49cb65..0257001a4 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -30,8 +30,8 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 9743a1e12..d3cfca705 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -43,8 +43,6 @@ import noppes.npcs.entity.EntityNPCInterface; import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.item.ScriptItemStack; public class PacketHandlerClient extends PacketHandlerServer{ diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 1849561e0..53d36a672 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -10,13 +10,12 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerCustomGui; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.CustomGuiEvent; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import java.io.IOException; @@ -78,7 +77,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onSlotChange(CustomGuiEvent.SlotEvent event) { @@ -87,7 +86,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SLOT, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onCustomGuiUnfocused(CustomGuiEvent.UnfocusedEvent event) { @@ -96,7 +95,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_TEXTFIELD, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onScrollClick(CustomGuiEvent.ScrollEvent event) { @@ -105,7 +104,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onClose(CustomGuiEvent.CloseEvent event) { @@ -113,7 +112,7 @@ public class CustomGuiController { ScriptController.Instance.playerScripts.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static ScriptGui getOpenGui(EntityPlayer player) { diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/Quest.java index 739b32010..cdc92a150 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/Quest.java @@ -17,13 +17,13 @@ import noppes.npcs.quests.QuestItem; import noppes.npcs.quests.QuestKill; import noppes.npcs.quests.QuestLocation; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.wrapper.NpcAPI; public class Quest implements ICompatibilty, IQuest { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 3697a54d9..1cc4d8a9f 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -18,10 +18,8 @@ import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcs; import noppes.npcs.NBTTags; -import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.EnumScriptType; -import noppes.npcs.scripted.NpcAPI; -import scala.Char; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptContainer { private static final String lock = "lock"; diff --git a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java index 74d1e43ee..f4e548b1b 100644 --- a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java @@ -21,9 +21,6 @@ import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; - -import javax.script.ScriptEngine; public class ForgeDataScript implements IScriptHandler { private List scripts = new ArrayList(); diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 7438a5660..4f8991bd2 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -19,10 +19,10 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.EventHooks; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.wrapper.NpcAPI; import org.lwjgl.opengl.GL11; public class ItemScripted extends Item implements ItemRenderInterface { diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java similarity index 90% rename from src/main/java/noppes/npcs/scripted/NpcAPI.java rename to src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java index 0280d43b2..0a9a2847d 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java @@ -24,10 +24,10 @@ import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; -public abstract class NpcAPI { - private static NpcAPI instance = null; +public abstract class AbstractNpcAPI { + private static AbstractNpcAPI instance = null; - public NpcAPI() { + public AbstractNpcAPI() { } public abstract ICustomNpc createNPC(World var1); @@ -64,15 +64,15 @@ public abstract class NpcAPI { return Loader.isModLoaded("customnpcs"); } - public static NpcAPI Instance() { + public static AbstractNpcAPI Instance() { if (instance != null) { return instance; } else if (!IsAvailable()) { return null; } else { try { - Class c = Class.forName("noppes.npcs.scripted.wrapper.WrapperNpcAPI"); - instance = (NpcAPI) c.getMethod("Instance").invoke((Object) null); + Class c = Class.forName("noppes.npcs.scripted.wrapper.NpcAPI"); + instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null); } catch (Exception var1) { var1.printStackTrace(); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index d7ab06245..1426c638e 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.util.LRUHashMap; public class ScriptBlock implements IBlock { diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index a607d1431..ab4625e12 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -16,6 +16,7 @@ import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptContainer implements IContainer { private IInventory inventory; diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java index 5eb9e3966..a4ddb2408 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -1,12 +1,12 @@ package noppes.npcs.scripted; -import jdk.nashorn.internal.ir.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.ITileEntity; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptTileEntity implements ITileEntity { protected T tileEntity; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 61af7f4d7..f71528d65 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -31,7 +31,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -325,7 +325,7 @@ public class ScriptWorld implements IWorld { * @return Returns the item */ public IItemStack createItem(String id, int damage, int size){ - return WrapperNpcAPI.Instance().createItem(id,damage,size); + return NpcAPI.Instance().createItem(id,damage,size); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 5752053c6..f07bd9efe 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -6,7 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptDBCPlayer extends ScriptPlayer{ public T player; @@ -432,10 +432,10 @@ public class ScriptDBCPlayer extends ScriptPlayer{ this.player.writeToNBT(compound); NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); - ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()]; + IItemStack[] itemList = new IItemStack[list.tagCount()]; for (int i = 0; i < list.tagCount(); i++) { ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); - itemList[i] = new ScriptItemStack(itemStack); + itemList[i] = NpcAPI.Instance().getIItemStack(itemStack); } return itemList; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 461825c64..a143acf7e 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -29,6 +29,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptEntity implements IEntity { protected T entity; @@ -740,6 +741,6 @@ public class ScriptEntity implements IEntity { } public ScriptWorld getWorld() { - return (ScriptWorld)NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj); + return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj); } } \ No newline at end of file diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 8f41c8971..5b8ea05c0 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -11,8 +11,8 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.scripted.wrapper.ScriptDamageSource; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; public class ScriptLivingBase extends ScriptEntity implements IEntityLivingBase { protected T entity; @@ -174,7 +174,7 @@ public class ScriptLivingBase extends ScriptEntity extends ScriptEntity extends ScriptLiving imp * @return The item held in the right hand */ public IItemStack getRightItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); + return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); } /** @@ -380,7 +380,7 @@ public class ScriptNpc extends ScriptLiving imp * @return The item held in the left hand */ public IItemStack getLefttItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.getOffHand()); + return NpcAPI.Instance().getIItemStack(npc.getOffHand()); } /** @@ -398,7 +398,7 @@ public class ScriptNpc extends ScriptLiving imp * @return Returns the projectile the npc uses */ public IItemStack getProjectileItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); + return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); } /** @@ -483,7 +483,7 @@ public class ScriptNpc extends ScriptLiving imp */ @Override public IItemStack getArmor(int slot){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); + return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); } /** @@ -506,7 +506,7 @@ public class ScriptNpc extends ScriptLiving imp * @return */ public IItemStack getLootItem(int slot) { - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); + return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 9ceb1083b..8d3ed0a61 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -28,7 +28,7 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; @@ -247,7 +247,7 @@ public class ScriptPlayer extends ScriptLivingBase for(int i = 0; i < player.inventory.mainInventory.length; i++){ ItemStack item = player.inventory.mainInventory[i]; if(item != null) - items[i] = WrapperNpcAPI.Instance().getIItemStack(item); + items[i] = NpcAPI.Instance().getIItemStack(item); } return items; } diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index d7f46473f..537a889c1 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -6,10 +6,10 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Event; -import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.AbstractNpcAPI; public class CustomNPCsEvent extends Event{ - public final NpcAPI API = NpcAPI.Instance(); + public final AbstractNpcAPI API = AbstractNpcAPI.Instance(); public CustomNPCsEvent() { } diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 679db5203..15cafafee 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -1,19 +1,19 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ItemEvent extends CustomNPCsEvent { - public ICustomItem item; + public IItemCustom item; - public ItemEvent(ICustomItem item) { + public ItemEvent(IItemCustom item) { this.item = item; } public static class InitEvent extends ItemEvent { - public InitEvent(ICustomItem item) { + public InitEvent(IItemCustom item) { super(item); } } @@ -21,7 +21,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class UpdateEvent extends ItemEvent { public IEntity entity; - public UpdateEvent(ICustomItem item, IEntity entity) { + public UpdateEvent(IItemCustom item, IEntity entity) { super(item); this.entity = entity; } @@ -32,7 +32,7 @@ public class ItemEvent extends CustomNPCsEvent { public IEntity entity; public IPlayer player; - public TossedEvent(ICustomItem item, IPlayer player, IEntity entity) { + public TossedEvent(IItemCustom item, IPlayer player, IEntity entity) { super(item); this.entity = entity; this.player = player; @@ -42,7 +42,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class PickedUpEvent extends ItemEvent { public IPlayer player; - public PickedUpEvent(ICustomItem item, IPlayer player) { + public PickedUpEvent(IItemCustom item, IPlayer player) { super(item); this.player = player; } @@ -51,7 +51,7 @@ public class ItemEvent extends CustomNPCsEvent { @Cancelable public static class SpawnEvent extends ItemEvent { public IEntity entity; - public SpawnEvent(ICustomItem item, IEntity entity){ + public SpawnEvent(IItemCustom item, IEntity entity){ super(item); this.entity = entity; } @@ -63,7 +63,7 @@ public class ItemEvent extends CustomNPCsEvent { public final Object target; public IPlayer player; - public InteractEvent(ICustomItem item, IPlayer player, int type, Object target) { + public InteractEvent(IItemCustom item, IPlayer player, int type, Object target) { super(item); this.type = type; this.target = target; @@ -77,7 +77,7 @@ public class ItemEvent extends CustomNPCsEvent { public final Object target; public IEntity swingingEntity; - public AttackEvent(ICustomItem item, IEntity swingingEntity, int type, Object target) { + public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, Object target) { super(item); this.type = type; this.target = target; @@ -89,7 +89,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public StartUsingItem(ICustomItem item, IPlayer player, int duration){ + public StartUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -99,7 +99,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public UsingItem(ICustomItem item, IPlayer player, int duration){ + public UsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -109,7 +109,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public StopUsingItem(ICustomItem item, IPlayer player, int duration){ + public StopUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -119,7 +119,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public FinishUsingItem(ICustomItem item, IPlayer player, int duration){ + public FinishUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index e0ffe6a8c..03de543d6 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -12,13 +12,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class NpcEvent extends CustomNPCsEvent { public final ICustomNpc npc; diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index f702353a2..390f8279a 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IEntity; @@ -21,6 +20,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class PlayerEvent extends CustomNPCsEvent { public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java index 9bd829d73..2697c47da 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java @@ -3,9 +3,9 @@ package noppes.npcs.scripted.gui; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.gui.IItemSlot; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot { IItemStack stack; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index 5080ad2ae..561ddca1c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -6,9 +6,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptTileEntity; public interface IBlock { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java index ca2dd8e9e..e46dc7978 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java @@ -1,10 +1,6 @@ package noppes.npcs.scripted.interfaces; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.ScriptWorld; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java index 69f2bbbe3..2b9e6d624 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java @@ -6,10 +6,6 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.ScriptBlockPos; import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.entity.ScriptEntity; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java new file mode 100644 index 000000000..1b4a9c3e6 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java @@ -0,0 +1,7 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemArmor { + int getArmorSlot(); + + String getArmorMaterial(); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java new file mode 100644 index 000000000..6776a81ec --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java @@ -0,0 +1,5 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemBlock { + String getBlockName(); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java new file mode 100644 index 000000000..87d72e3fa --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java @@ -0,0 +1,15 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemBook { + String[] getText(); + + void setText(String[] var1); + + String getAuthor(); + + void setAuthor(String var1); + + String getTitle(); + + void setTitle(String var1); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java similarity index 97% rename from src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java rename to src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java index 9ee43e389..e36e84907 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java @@ -1,6 +1,6 @@ package noppes.npcs.scripted.interfaces.item; -public interface ICustomItem extends IItemStack { +public interface IItemCustom extends IItemStack { String getTexture(); void setTexture(String var2); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 721e3b694..f0a683a22 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -10,11 +10,11 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import java.util.*; -public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IScriptHandler { +public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IScriptHandler { public List scripts = new ArrayList(); public String scriptLanguage = "ECMAScript"; public boolean enabled = false; diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java new file mode 100644 index 000000000..473db92bf --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java @@ -0,0 +1,19 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemArmor; + +public class ScriptItemArmor extends ScriptItemStack implements IItemArmor { + + public ScriptItemArmor(ItemStack item) { + super(item); + } + + public int getArmorSlot() { + return 0; + } + + public String getArmorMaterial() { + return null; + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java new file mode 100644 index 000000000..fee327802 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java @@ -0,0 +1,15 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemBlock; + +public class ScriptItemBlock extends ScriptItemStack implements IItemBlock { + + public ScriptItemBlock(ItemStack item) { + super(item); + } + + public String getBlockName() { + return null; + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java new file mode 100644 index 000000000..7c59158ad --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java @@ -0,0 +1,35 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemBook; + +public class ScriptItemBook extends ScriptItemStack implements IItemBook { + + public ScriptItemBook(ItemStack item) { + super(item); + } + + public String[] getText() { + return new String[0]; + } + + public void setText(String[] var1) { + + } + + public String getAuthor() { + return null; + } + + public void setAuthor(String var1) { + + } + + public String getTitle() { + return null; + } + + public void setTitle(String var1) { + + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 09909fbfa..ea5ddad32 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -19,10 +19,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptNbt; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.INbt; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptItemStack implements IItemStack { public ItemStack item; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java similarity index 97% rename from src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java rename to src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java index a83d1f353..bebe92068 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java @@ -45,7 +45,7 @@ import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.gui.ICustomGui; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptCustomItem; @@ -55,12 +55,12 @@ import noppes.npcs.util.JsonException; import noppes.npcs.util.LRUHashMap; import noppes.npcs.util.NBTJsonUtil; -public class WrapperNpcAPI extends NpcAPI { +public class NpcAPI extends AbstractNpcAPI { private static final Map worldCache = new LRUHashMap(10); public static final EventBus EVENT_BUS = new EventBus(); - private static NpcAPI instance = null; + private static AbstractNpcAPI instance = null; - public WrapperNpcAPI() { + public NpcAPI() { } public static void clearCache() { @@ -163,9 +163,9 @@ public class WrapperNpcAPI extends NpcAPI { } } - public static NpcAPI Instance() { + public static AbstractNpcAPI Instance() { if (instance == null) { - instance = new WrapperNpcAPI(); + instance = new NpcAPI(); } return instance; @@ -177,12 +177,22 @@ public class WrapperNpcAPI extends NpcAPI { public IItemStack getIItemStack(ItemStack itemstack) { if(itemstack.getItem() instanceof ItemScripted){ - return (ICustomItem) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); + return (IItemCustom) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); } else { return (IItemStack) (itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); } } + public IItemStack createItem(String id, int damage, int size){ + Item item = (Item)Item.itemRegistry.getObject(id); + if(item == null) + return null; + if(item instanceof ItemScripted) + return new ScriptCustomItem(new ItemStack(item, size, damage)); + else + return new ScriptItemStack(new ItemStack(item, size, damage)); + } + public IWorld getIWorld(WorldServer world) { ScriptWorld w = (ScriptWorld)worldCache.get(world.provider.dimensionId); if (w != null) { @@ -270,16 +280,6 @@ public class WrapperNpcAPI extends NpcAPI { return arr; } - public IItemStack createItem(String id, int damage, int size){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) - return null; - if(item instanceof ItemScripted) - return new ScriptCustomItem(new ItemStack(item, size, damage)); - else - return new ScriptItemStack(new ItemStack(item, size, damage)); - } - public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); }