[Solved]ArrayOutOfBoundsException

Plugin specific problems will be solved here.

Moderator: Plugin Moderators

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

[Solved]ArrayOutOfBoundsException

#1

Post by Mayor Jeffrey IX »

Problem is as follows:

Plugin Error

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

#2

Post by Lobby »

Without code it's difficult to help. You probably didn't provide frames.

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#3

Post by Mayor Jeffrey IX »

Image
Image
I have all seven frames (wr1, wr2, wr3, wr4, wr5, wr6, basewindmill).
Last edited by Mayor Jeffrey IX on 01 May 2017, 20:00, edited 1 time in total.

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

#4

Post by Lobby »

It would be a lot more easy if you could paste the code directly into the forum using the

Code: Select all

-tags. Also the error message tells you where it occurred, that might be helpful.

It's most likely that there's a mistake in your image names.

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#5

Post by Mayor Jeffrey IX »

Code: Select all

[
{
"id": "wind_rotor01",
"type": "animation",
"frames": [
{"bmp": "wr1.png"},
{"bmp": "wr2.png"},
{"bmp": "wr3.png"},
{"bmp": "wr4.png"},
{"bmp": "wr5.png"},
{"bmp": "wr6.png"}
]
},
{
"id":"floatingwindturbine",
"width": 4,
"height": 4,
"frames": [{"bmp":"basewindturbine.png"}],
"type": "energy",
"needs water": true,
"needs land": false,
"power": 1000,
"draw ground":true,
"price": 8000,
"monthly price": 60,
"needs road": false,
"water": 0,
"influence noise": 35,
"animation":[{"id":"wind_rotor01","x":0,"y":-85}],
"requirement": {
"requirements":
[
{
"type": "HABITANT_COUNT",
"data": {
"count": 300
}
}
]
}
}
]
Man I am such a noob
Image

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#6

Post by Mayor Jeffrey IX »

So do you have an idea of what could be wrong?

User avatar
BetterBear
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2896
Joined: 18 Apr 2017, 09:03
Location: In a place you don't expect.
Plugins: Showcase Store
Version: Beta

Platform

#7

Post by BetterBear »

Mayor Jeffrey IX wrote:So do you have an idea of what could be wrong?
I think because he wrote

Code: Select all

"type": HABITANT_COUNT,
And since its a wind turbine, I should be:

Code: Select all

"type":"energy",
Still not sure

User avatar
Josh
Graphic designer
Reactions:
Posts: 2214
Joined: 11 Mar 2017, 19:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

#8

Post by Josh »

Or do you mean how many habitants, than instead of

Code: Select all

"type": "HABITANT_COUNT", 
"data": { 
"count": 300 
You need to do

Code: Select all

"habitans":300

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

#9

Post by Lobby »

It looks as if it doesn't see the contents of your JSON File :roll:

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#10

Post by Mayor Jeffrey IX »

@BetterBear
This

Code: Select all

"requirement": {
"requirements":
[
{
"type":"HABITANT_COUNT",
"data": {
"count": 300
}
}
]
}
is a seperate line of code, and if you look at the top, you'll see

Code: Select all

"type": "energy",
I know this works 'cause I've used this in other plugins.

@Lobby
Hmmm that's odd... not sure what could cause that.

User avatar
Josh
Graphic designer
Reactions:
Posts: 2214
Joined: 11 Mar 2017, 19:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

#11

Post by Josh »

Do you want a certain amount of habitans to achieve this building?

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

#12

Post by CommanderABab »

I think that he is trying to make it like the regular wind turbine.

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#13

Post by Mayor Jeffrey IX »

I'd like to get it to get unlocked by rank, but that's not the problem. The problem is the error message (see top).

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#14

Post by Mayor Jeffrey IX »

All I want to know is what the error message means.

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

#15

Post by CommanderABab »

The width and height of the regular wind turbine is 3x3.

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#16

Post by Mayor Jeffrey IX »

Ok, I planned it to be 4x4. It's going to be kind of an upgrade to the current one. Not literally.

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

#17

Post by Lobby »

You might consider to send us your current progress to info@theotown.de so we can have a look at it. The error message alone doesn't tell enough about the issue.

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#18

Post by Mayor Jeffrey IX »

I figured out the problem!

It turns out I need to put an actual number of frames.
For example:
I need to change this

Code: Select all

[ 
{ 
"id": "wind_rotor01", 
"type": "animation", 
"frames": [ 
{"bmp": "wr1.png"}, 
{"bmp": "wr2.png"}, 
{"bmp": "wr3.png"}, 
{"bmp": "wr4.png"}, 
{"bmp": "wr5.png"}, 
{"bmp": "wr6.png"} 
] 
}, 
to this

Code: Select all

[ 
{ 
"id": "wind_rotor01", 
"type": "animation", 
"count": 6,
"frames": [ 
{"bmp": "wr1.png"}, 
{"bmp": "wr2.png"}, 
{"bmp": "wr3.png"}, 
{"bmp": "wr4.png"}, 
{"bmp": "wr5.png"}, 
{"bmp": "wr6.png"} 
] 
}, 
That count specifies how many frames there are.

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

#19

Post by Lobby »

That's strange, we don't read a count attribute for animation plugins :roll:

User avatar
Mayor Jeffrey IX
TheoTown Cartographer
Reactions:
Posts: 988
Joined: 05 Apr 2017, 16:48
Location: Right here
Plugins: Showcase Store

Platform

#20

Post by Mayor Jeffrey IX »

Well, it works now so I'm not gonna complain

Post Reply Previous topicNext topic

Return to “Problems”