Minecraft bukkit spigot插件传送到另一个世界会导致崩溃:服务器滴答循环中发生异常

问题描述

我正在为我的minecraft服务器创建一个插件,其目的是为了发出命令以传送到另一个富有创造力的超扁平世界。问题是当播放器被传送时,服务器崩溃了。 这是我在插件中的代码

// go world commands
        if (cmd.getName().equals("goworld")) {
            if (args.length == 0){
                sender.sendMessage(ChatColor.DARK_RED + "World not specified");
            } else {
                // calculate closest player
                double closest = Double.MAX_VALUE;
                Player closestp = null;
                for(Player i : Bukkit.getonlinePlayers()){
                    double dist = i.getLocation().distance(blockLoc);
                    if (closest == Double.MAX_VALUE || dist < closest){
                        closest = dist;
                        closestp = i;
                    }
                }
                if (closestp == null){
                    //No players found
                }
                else{
                    //the closest player is closestp
                    closestp.sendMessage(ChatColor.BLUE + "Taking you to " + worldToGo);
                    try {
                        JSONObject worldPref = (JSONObject) readJsonSimple(worldToGo + "\\startpos.json");
                        System.out.println(worldPref.toJSONString());
                        System.out.println(worldPref.get("x"));
                        System.out.println(worldPref.get("y"));
                        System.out.println(worldPref.get("z"));
                        System.out.println(worldPref.get("pitch"));
                        System.out.println(worldPref.get("yaw"));
                        System.out.println(worldPref.get("world"));
                        List<World> worlds = Bukkit.getWorlds();
                        for (World world : worlds) {
                            System.out.println("#########");
                            System.out.println(world.getName());
                        }
                        System.out.println("--------------");
                        System.out.println(worldPref.get("world").toString());
                        World newWorld = new WorldCreator(worldToGo).createWorld();
                        System.out.println(newWorld);
                        updateLastPos(closestp);
                        closestp.teleport(
                                new Location(
                                        newWorld,(long)worldPref.get("x"),(long)worldPref.get("y"),(long)worldPref.get("z")
                                )
                        );
                        closestp.sendMessage(ChatColor.GREEN + "You have entered " + worldToGo);
                    } catch (Exception e) {
                        e.printstacktrace();
                        closestp.sendMessage(ChatColor.RED + "Something went wrong");
                    }
                }
            }
        }

这是服务器创建的错误

[18:51:54] [Worker-Main-12/INFO]: Preparing spawn area: 96%
[18:51:54] [Server thread/INFO]: Time elapsed: 6911 ms
[18:51:54] [Server thread/INFO]: [WorldGuard] (world_ntischool) TNT ignition is PERMITTED.
[18:51:54] [Server thread/INFO]: [WorldGuard] (world_ntischool) Lighters are PERMITTED.
[18:51:54] [Server thread/INFO]: [WorldGuard] (world_ntischool) Lava fire is PERMITTED.
[18:51:54] [Server thread/INFO]: [WorldGuard] (world_ntischool) Fire spread is UNRESTRICTED.
[18:51:54] [Server thread/INFO]: [WorldGuard] Loaded configuration for world 'world_ntischool'
[18:51:54] [Server thread/INFO]: CraftWorld{name=world_ntischool}

[18:51:54] [Server thread/ERROR]: Encountered an unexpected exception
java.util.ConcurrentModificationException: null
    at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:758) ~[?:?]
    at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:785) ~[?:?]
    at net.minecraft.server.v1_16_R2.minecraftServer.b(minecraftServer.java:1087) ~[spigot-1.16.2.jar:git-Spigot-d65430a-bad55db]
    at net.minecraft.server.v1_16_R2.DedicatedServer.b(DedicatedServer.java:352) ~[spigot-1.16.2.jar:git-Spigot-d65430a-bad55db]
    at net.minecraft.server.v1_16_R2.minecraftServer.a(minecraftServer.java:1007) ~[spigot-1.16.2.jar:git-Spigot-d65430a-bad55db]
    at net.minecraft.server.v1_16_R2.minecraftServer.w(minecraftServer.java:846) ~[spigot-1.16.2.jar:git-Spigot-d65430a-bad55db]
    at net.minecraft.server.v1_16_R2.minecraftServer.lambda$0(minecraftServer.java:164) ~[spigot-1.16.2.jar:git-Spigot-d65430a-bad55db]
    at java.lang.Thread.run(Thread.java:832) [?:?]

就在服务器崩溃之前,我可以看到我已经被传送到另一个位置,但是仍然和以前一样。开始备份并重新登录时,可以看到我像以前一样被传送到了另一个世界。

编辑: 我尝试添加,以便服务器创建一个新世界并将其传送到生成点,但服务器仍然崩溃,游戏超时。

我该如何解决。谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)