Jump to content

Inventory.getItemAt() exception


pepsip77
 Share

Recommended Posts

WARNING: Uncaught exception from task:
java.lang.ArrayIndexOutOfBoundsException: 1
        at xobot.script.methods.tabs.Inventory.getItemAt(qa:15)
        at pepsip77.pFisher.customListeners.Inventory.InventoryEventSource.<init
>(InventoryEventSource.java:19)
        at pepsip77.pFisher.customListeners.EventDispatcher.<init>(EventDispatch
er.java:27)
        at pFisher.onStart(pFisher.java:42)
        at xobot.Ha.run(ya:49)
        at java.lang.Thread.run(Unknown Source)

Inventory.getItemAt() throws exception, when trying to get item at empty spot

Link to comment
Share on other sites

Thanks for reporting I'll check it out :)

1 hour ago, pepsip77 said:

there is no edit button :|

suggestion:
 


	public static Item getItemAtSlot(int slot) {
		for(Item item : Inventory.getItems()) {
			if(item.getSlot() == slot)
				return item;
		}
		return null;
	}

 

Fixed editing :P thanks!

Link to comment
Share on other sites

Bug fixed here's a better version without having to loop all the items

	public static Item getItemAt(final int index) {
		Item[] inv = getItems();
		Item i = inv.length > index ? inv[index] : null;
		return i != null && i.getSlot() == index ? i : null;
	}

 

Link to comment
Share on other sites

  • Neo locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...