错误,Mincraft插件记分牌

时间:2016-07-25 10:17:19

标签: java plugins minecraft

我收到以下错误代码:

[21:55:37 ERROR]: Could not pass event PlayerChangedWorldEvent to LuckySkyPvP v1.1
org.bukkit.event.EventException
  at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.PlayerList.moveToWorld(PlayerList.java:628) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer.teleport(CraftPlayer.java:471) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity.teleport(CraftEntity.java:226) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter.safelyTeleport(SimpleSafeTTeleporter.java:215) [Multiverse-Core-2.5.0-SNAPSHOT(1).jar:?]
  at com.onarandombox.MultiversePortals.listeners.PlayerListenerHelper.performTeleport(PlayerListenerHelper.java:44) [Multiverse-Portals-2.5.jar:?]
  at com.onarandombox.MultiversePortals.listeners.MVPPlayerMoveListener.playerMove(MVPPlayerMoveListener.java:137) [Multiverse-Portals-2.5.jar:?]
  at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) ~[?:?]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71]
  at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71]
  at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_71]
  at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.7.0_71]
  at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  at java.lang.Thread.run(Unknown Source) [?:1.7.0_71]
Caused by: java.util.ConcurrentModificationException
  at java.util.HashMap$HashIterator.nextEntry(Unknown Source) ~[?:1.7.0_71]
  at java.util.HashMap$KeyIterator.next(Unknown Source) ~[?:1.7.0_71]
  at SkyPvPTobiasS.ScoreBoardClass.onWorldChange(ScoreBoardClass.java:165) ~[?:?]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71]
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71]
  at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71]
  at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[craftbukkit.jar:git-Spigot-5f38d38-12698ea]
  ... 28 more

这是代码的一部分:

for(Scoreboard key : boards.keySet()) {
    if(boards.get(key).equals(e.getPlayer())) {
        boards.remove(key);
    }
}

代码必须删除旧的记分板密钥,然后创建一个新的记分板,因为在一个世界中是一个记分板,在另一个世界中是另一个世界。

但是,如果我改变世界,它有时会在代码的这一部分不起作用,并显示错误。

1 个答案:

答案 0 :(得分:0)

执行此操作时:

for(Scoreboard key : boards.keySet()) {
    if(boards.get(key).equals(e.getPlayer())) {
        boards.remove(key);
    }
}

您正在按键阅读boards键。 问题是,当您尝试删除密钥时,您正在读取密钥。

尝试这样做并告诉我是否纠正了问题:

for(Scoreboard key : new HashSet<>(boards.keySet())) { // copy of the keySet before itterating
    if(boards.get(key).equals(e.getPlayer())) {
        boards.remove(key);
    }
}