Solved ClassCastException

Discussion in 'Spigot Plugin Development' started by Alex0589, Jul 30, 2018.

  1. Here's the line where I cast;
    Code (Text):
         nmsWorld = (net.minecraft.server.v1_13_R1.World) world;
    I'm casting net.minecraft.server.World to org.bukkit.World, but I get an error:
    Code (Text):
     java.lang.ClassCastException: org.bukkit.craftbukkit.v1_13_R1.CraftWorld cannot be cast to net.minecraft.server.v1_13_R1.World
    [14:40:39 WARN]:        at current.NmsHandler.installBiomeGenerator(NmsHandler.java:25)
    [14:40:39 WARN]:        at bukkit.plugin.BiomeGeneratorListener.onChunkLoad(BiomeGeneratorListener.java:89)
    [14:40:39 WARN]:        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    [14:40:39 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    [14:40:39 WARN]:        at java.lang.reflect.Method.invoke(Unknown Source)
    [14:40:39 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304)
    [14:40:39 WARN]:        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [14:40:39 WARN]:        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500)
    [14:40:39 WARN]:        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkMap.a(ChunkMap.java:41)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:134)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkMap.put(ChunkMap.java:1)
    [14:40:39 WARN]:        at org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectMaps$SynchronizedMap.put(Long2ObjectMaps.java:371)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkProviderServer.a(ChunkProviderServer.java:207)
    [14:40:39 WARN]:        at java.util.concurrent.CompletableFuture.uniApply(Unknown Source)
    [14:40:39 WARN]:        at java.util.concurrent.CompletableFuture.uniApplyStage(Unknown Source)
    [14:40:39 WARN]:        at java.util.concurrent.CompletableFuture.thenApply(Unknown Source)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkProviderServer.generateChunk(ChunkProviderServer.java:169)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:127)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.World.getChunkAt(World.java:268)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:209)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.WorldProviderNormal.a(SourceFile:186)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.b(WorldServer.java:821)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.WorldServer.a(WorldServer.java:731)
    [14:40:39 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.createWorld(CraftServer.java:942)
    [14:40:39 WARN]:        at org.bukkit.Bukkit.createWorld(Bukkit.java:456)
    [14:40:39 WARN]:        at org.bukkit.WorldCreator.createWorld(WorldCreator.java:261)
    [14:40:39 WARN]:        at com.onarandombox.MultiverseCore.utils.WorldManager.doLoad(WorldManager.java:466)
    [14:40:39 WARN]:        at com.onarandombox.MultiverseCore.utils.WorldManager.addWorld(WorldManager.java:268)
    [14:40:39 WARN]:        at com.onarandombox.MultiverseCore.commands.CreateCommand.runCommand(CreateCommand.java:114)
    [14:40:39 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.checkAndRunCommand(CommandHandler.java:279)
    [14:40:39 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.processFoundCommands(CommandHandler.java:143)
    [14:40:39 WARN]:        at com.pneumaticraft.commandhandler.multiverse.CommandHandler.locateAndRunCommand(CommandHandler.java:93)
    [14:40:39 WARN]:        at com.onarandombox.MultiverseCore.MultiverseCore.onCommand(MultiverseCore.java:916)
    [14:40:39 WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    [14:40:39 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [14:40:39 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchCommand(CraftServer.java:692)
    [14:40:39 WARN]:        at org.bukkit.craftbukkit.v1_13_R1.CraftServer.dispatchServerCommand(CraftServer.java:677)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.DedicatedServer.aW(DedicatedServer.java:453)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.DedicatedServer.w(DedicatedServer.java:412)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.MinecraftServer.v(MinecraftServer.java:819)
    [14:40:39 WARN]:        at net.minecraft.server.v1_13_R1.MinecraftServer.run(MinecraftServer.java:717)
    [14:40:39 WARN]:        at java.lang.Thread.run(Unknown Source)
    How can I fix it?
     
  2. Maybe I solved it
     
  3. Use world.getHandle();