Cannot use `mods.zenutils.StaticString.join` to join string array
Closed this issue · 5 comments
Seems like mods.zenutils.StaticString.join
should work with any types of CraftTweaker arrays, but it cant work with string[]
Both this lines erroring:
print(mods.zenutils.StaticString.join(['a','b'], ','));
print(mods.zenutils.StaticString.join(['a','b'] as string[], ','));
Error in crafttweaker.log
:
12 methods available but none matches the parameters (string[], string)
This is usually an error in your script, not in the mod
join(short[], string)
join(float[], string)
join(double[], string)
join(int[], string)
join(long[], string)
join(ZenTypeNative: java.lang.Object[], string)
join(float[], string, int, int)
join(ZenTypeNative: java.lang.Object[], string, int, int)
join(int[], string, int, int)
join(long[], string, int, int)
join(short[], string, int, int)
join(double[], string, int, int)
I dont know Java well, but considering latest commit, maybe this function should be changed too?
ZenUtils/src/main/java/youyihj/zenutils/api/util/StaticString.java
Lines 735 to 738 in ac9e64a
This method is no problem. The issue is string[]
is not Object[]
, ZS needs to cast string[]
to another array, but there is other methods that accept int[]
float[]
. string[]
can be cast to these array type, too. So ZS doesn't know which array type to cast to, and use which method then.
Is that means i cant use startIndex
and endIndex
for joining string[]
array at all?
This zs code have error too:
print(mods.zenutils.StaticString.join(['a','b'] as string[], ',', 0, 1));
12 methods available but none matches the parameters (string[], string, int, int)
Oh, there also is conflicted method that accept int[], string, int, int
. Is this problem urgent? If not, I'm going to fix it in next update.
No, its not urgent. I will use my own implementation of join 😀
https://github.com/Krutoy242/Craft.zs/blob/885c0ee8e0029fa3b8303242d0d468c393d4161e/serialize.zs#L34-L43