its an index out of bounds exception, says it on the very first line.
|
this is in the server when i try to sell an item after attempting to add sell xCode:[2/17/17 3:51 PM]: java.lang.ArrayIndexOutOfBoundsException: 101 [2/17/17 3:51 PM]: at server.model.shops.ShopAssistant.addShopItem(ShopAssistant.java:637) [2/17/17 3:51 PM]: at server.model.shops.ShopAssistant.sellItem(ShopAssistant.java:601) [2/17/17 3:51 PM]: at server.model.players.packets.Bank5.processPacket(Bank5.java:23) [2/17/17 3:51 PM]: at server.model.players.PacketHandler.processPacket(PacketHandler.java:137) [2/17/17 3:51 PM]: at server.model.players.Client.processQueuedPackets(Client.java:1900) [2/17/17 3:51 PM]: at server.model.players.PlayerHandler.process(PlayerHandler.java:149) [2/17/17 3:51 PM]: at server.Server.main(Server.java:186)
its an index out of bounds exception, says it on the very first line.
would you happen to know how to fix this? i dont get this error on my test servers but for some reason on this one i do get it
Post your code at server.model.shops.ShopAssistant.addShopItem(ShopA ssistant.java:637) and I can attempt to assist you. Basically what is happening is that you have an array of example 12 elements, you try add a 13th element and that's the error you will receive. So from the looks of it, you are trying to input an index that is out of bounds of the array.
It's real simple ... whatever your issue is with shops...
Well you see here is the thing...you first need to understand what an array is in general terms
http://docs.oracle.com/javase/tutori...ts/arrays.html
amazing what you can find from a google search
http://docs.oracle.com/javase/7/docs...-external=true
public class ArrayIndexOutOfBoundsException
extends IndexOutOfBoundsException
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
Code:public boolean addShopItem(int itemID, int amount) { boolean Added = false; if (amount <= 0) { return false; } if (Item.itemIsNote[itemID] == true) { itemID = c.getItems().getUnnotedItem(itemID); } for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) { if ((Server.shopHandler.ShopItems[c.myShopId][i] - 1) == itemID) { Server.shopHandler.ShopItemsN[c.myShopId][i] += amount; Added = true; } } if (Added == false) { for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) { if (Server.shopHandler.ShopItems[c.myShopId][i] == 0) { Server.shopHandler.ShopItems[c.myShopId][i] = (itemID + 1); Server.shopHandler.ShopItemsN[c.myShopId][i] = amount; Server.shopHandler.ShopItemsDelay[c.myShopId][i] = 0; break; } } } return true; }
Okay I have a few questions before I could try assist you.
- Did you write this piece of code?
- Is ShopItems.length the amount of items in a shop?
- Where are you calling this method from and what values are you inserting in the method parameters?
Haven't coded rsps before so don't know the classes.
Are you trying to sell an item in a full shop or just any shop?
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |