mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 04:35:03 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -23,11 +23,12 @@ import noppes.npcs.scripted.event.ItemEvent;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ScriptItemEventHandler {
|
||||
public ScriptItemEventHandler() {}
|
||||
public ScriptItemEventHandler() {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingEvent.LivingUpdateEvent event) {
|
||||
if(event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted%10 != 0)
|
||||
if (event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted % 10 != 0)
|
||||
return;
|
||||
|
||||
if (event.entityLiving instanceof EntityCustomNpc) {
|
||||
@@ -43,7 +44,7 @@ public class ScriptItemEventHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
} else if (event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem());
|
||||
EventHooks.onScriptItemUpdate((IItemCustomizable) itemStack, event.entityLiving);
|
||||
}
|
||||
@@ -51,177 +52,186 @@ public class ScriptItemEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(ItemTossEvent event) {
|
||||
if(event.player == null || event.player.worldObj == null)
|
||||
if (event.player == null || event.player.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
if (event.player.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (NoppesUtilServer.isScriptableItem(event.entityItem.getEntityItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityItem.getEntityItem());
|
||||
if(isw instanceof IItemCustomizable)
|
||||
if (isw instanceof IItemCustomizable)
|
||||
event.setCanceled(EventHooks.onScriptItemTossed((IItemCustomizable) isw, event.player, event.entityItem));
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerEvent.ItemPickupEvent event) {
|
||||
if(event.player == null || event.player.worldObj == null)
|
||||
if (event.player == null || event.player.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
if (event.player.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (NoppesUtilServer.isScriptableItem(event.player.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.player.getHeldItem());
|
||||
if(isw instanceof IItemCustomizable)
|
||||
if (isw instanceof IItemCustomizable)
|
||||
EventHooks.onScriptItemPickedUp((IItemCustomizable) isw, event.player);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(EntityJoinWorldEvent event) {
|
||||
if (!event.world.isRemote && event.entity instanceof EntityItem) {
|
||||
EntityItem entity = (EntityItem)event.entity;
|
||||
EntityItem entity = (EntityItem) event.entity;
|
||||
ItemStack stack = entity.getEntityItem();
|
||||
|
||||
try {
|
||||
if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) {
|
||||
if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(stack);
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if(EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
if (EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(EntityInteractEvent event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
return;
|
||||
|
||||
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemInteract((IItemCustomizable) isw, eve));
|
||||
|
||||
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
|
||||
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, rightClickEvent));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerInteractEvent event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer))
|
||||
if (event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer))
|
||||
return;
|
||||
|
||||
if (PlayerDataController.Instance != null) {
|
||||
if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){
|
||||
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
|
||||
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
if(handler == null)
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
if(handler.hadInteract) {
|
||||
if (handler.hadInteract) {
|
||||
handler.hadInteract = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null);
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
else if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
if(handler == null)
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
handler.hadInteract = true;
|
||||
try {
|
||||
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerUseItemEvent.Start event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
if (event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStartUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerUseItemEvent.Tick event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerUseItemEvent.Stop event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStopUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerUseItemEvent.Finish event) {
|
||||
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustomizable){
|
||||
if (isw instanceof IItemCustomizable) {
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
EventHooks.onFinishUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(AnvilRepairEvent repairEvent) {
|
||||
IItemStack output = NpcAPI.Instance().getIItemStack(repairEvent.output);
|
||||
|
||||
Reference in new issue
Block a user