-2

Earlier I posted this thread asking for how to make multiple values out of a for loop. After a while I ran into a problem, which I don't know how to fix nor know why it happened. This is the code that I have:

for(int x = 0; x < con.length; x++) 
{
    maxS[x] = main.getConfig().getString("areas." + con[x] + ".max").split(", ").toString();
    minS[x] = main.getConfig().getString("areas." + con[x] + ".min").split(", ").toString();
    event.getPlayer().sendMessage("1");
    for(int y = 0; y < maxS.length; y++) 
    {
        maxV[y] = new Vector(Integer.parseInt(maxS[y]), Integer.parseInt(maxS[y+1]), Integer.parseInt(maxS[y+2]));
        minV[y] = new Vector(Integer.parseInt(minS[y]), Integer.parseInt(minS[y+1]), Integer.parseInt(minS[y+2]));

        event.getPlayer().sendMessage("2");
    }
}

The error message:

2013-07-29 20:32:12 [SEVERE] Could not pass event PlayerMoveEvent to FactionPlay v1.6.2 org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:227)
at net.minecraft.server.v1_6_R2.Packet10Flying.handle(SourceFile:136)
at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296)
at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:116)
at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:30)
at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:590)
at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
Caused by: java.lang.NumberFormatException: For input string: " [Ljava.lang.String;@af7327" at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at me.BlueJelly.FactionPlay_SP.PlayerListener.onPlayerMove(PlayerListener.java:191)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
... 14 more

4

1 回答 1

2

从您的错误消息来看,看起来您的调用Integer.parseInt实际上并没有得到可以解析为 int 的字符串。

相反,他们得到了 string " [Ljava.lang.String;@af7327"

您应该重新评估如何获得这些字符串


以下行看起来是错误的。

maxS[x] = main.getConfig().getString("areas." + con[x] + ".max").split(", ").toString();

这可能只是我的 c# 经验,但我通常希望.split()调用返回一个数组string而不是单个string.

如果不查看您的其余代码很难判断,但我希望看到一条看起来更像下面的行

maxS = main.getConfig().getString("areas." + con[x] + ".max").split(", ");
于 2013-07-29T18:46:24.120 回答