ArrayList cannot be cast to Location

Discussion in 'Plugin Development' started by amatokus, Aug 21, 2015.

Thread Status:
Not open for further replies.
  1. Hi all, I'm having a problem:

    I've got this in my onEnable():

    Code:
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                @Override
                public void run() {
                ((Location)cfile.getList("money_chests")).getWorld().playEffect((Location) cfile.getList("money_chests"), Effect.SMOKE, 10);
                }
            },20, 40);
    And this error:

    Code:
    [21:08:16 WARN]: [MoneyChest] Task #287 for MoneyChest v0.1 generated an excepti
    on
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.bukkit.L
    ocation
            at me.amatokus8669.plugin.moneychest.MoneyChest$1.run(MoneyChest.java:86
    ) ~[?:?]
            at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftTask.run(CraftTask.java
    :53) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
            at org.bukkit.craftbukkit.v1_7_R3.scheduler.CraftScheduler.mainThreadHea
    rtbeat(CraftScheduler.java:345) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb4
    4-b3091jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:6
    00) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
            at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:2
    60) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:5
    58) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java
    :469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
            at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:6
    28) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-9-gaceeb44-b3091jnks]
    >
    How can I solve this? thanks
     
  2. Offline

    caderape

    @amatokus
    loops the list ad cast each string to location
     
  3. Offline

    RainoBoy97

    An ArrayList is not a Location, you cannot cast it.
     
  4. Offline

    flash1110

    Get all of the necessary items as variables (String, int, etc.) through the ArrayList. Then, create a new Location instance.
     
  5. Offline

    mythbusterma

    @amatokus

    Or actually serialize your Locations properly.
     
  6. Offline

    mythbusterma

  7. @mythbusterma Thanks a lot.

    @mythbusterma Nevermind I still didn't figure it out

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  8. Offline

    mythbusterma

Thread Status:
Not open for further replies.

Share This Page