14.02.2016, 17:17
@valych: You don't add the Integer.class at the end for the length, this is just a Pawn thing because the length of the array is not known when you pass it to the plugin. Your function should look like this:
The rest should be alright.
PHP код:
instance.registerFunction("java_TestArray", objects -> {
int someValue = (Integer) objects[0]; // in this line the java.lang.ClassCastException is being thrown (read below)
Integer[] array = (Integer[])objects[1];
for (int i = 0; i < array.length; i++) {
if(someValue == 33) {
array[i] = (i + 2) * 4;
} else {
array[i] = i+1;
}
}
return 1;
}, Integer.class, Integer[].class);