ServerPlugin Programmiertes plugin, fehlermeldung bei cast von cheat

Dieses Thema im Forum "Programmierung" wurde erstellt von chriarus, 22. Mai 2016.

  1. chriarus
    Offline

    chriarus

    Registriert seit:
    22. Mai 2016
    Beiträge:
    1
    Habe wiedermal ein problem mit Meinem Programmierten plugin.


    ich will den inhalt einer kiste dem user ausgeben wenn er auf das darüber befindende schild clickt.


    [11:53:50 ERROR]: Could not pass event PlayerInteractEvent to MoneyMonkey v1.0.0

    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:302) ~[craftbukkit.jar:git-Bukkit-935f18b]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-935f18b]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:501) [craftbukkit.jar:git-Bukkit-935f18b]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:486) [craftbukkit.jar:git-Bukkit-935f18b]
    at org.bukkit.craftbukkit.v1_9_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:231) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.PlayerInteractManager.a(PlayerInteractMa
    nager.java:482) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java
    :875) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.PacketPlayInUseItem.a(SourceFile:55) [cr
    aftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.PacketPlayInUseItem.a(SourceFile:11) [cr
    aftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:1
    3) [craftbukkit.jar:git-Bukkit-935f18b]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_60]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60]
    at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [craftbukki
    t.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:6
    79) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:3
    61) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:6
    35) [craftbukkit.jar:git-Bukkit-935f18b]
    at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java
    :539) [craftbukkit.jar:git-Bukkit-935f18b]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_9_R1.block.Cr
    aftBlock cannot be cast to org.bukkit.block.Chest
    at MoneyMonkey.x_onPlayerInteractEvent.onInterackt(x_onPlayerInteractEve
    nt.java:36) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
    _60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
    _60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:300) ~[craftbukkit.jar:git-Bukkit-935f18b]
    ... 17 more


    ich weis das ich laut fehlermeldun meinen block nicht zu einer kiste casten darf, aber wie soll ich das sonst anstellen das ich an den inhalt komme?



    @EventHandler
    public void onInterackt(PlayerInteractEvent e){

    Block b = e.getClickedBlock();
    Player p = e.getPlayer();

    if (b.getType() == Material.WALL_SIGN ) {

    //Sign s = (Sign) b;

    Location locS = b.getLocation();
    Location locK = new Location(locS.getWorld(), locS.getX(), locS.getY()-1, locS.getZ());

    Block b2 = locK.getBlock();

    if (b2.getType() == Material.CHEST){

    Chest c = (Chest) b2;
    Inventory inv = c.getBlockInventory();

    p.sendMessage(inv.toString());

    }

    }
    }



    ich hoffe ihr könnt mir helfen.
     
    #1
  2. GPSforLEGENDS
    Offline

    GPSforLEGENDS

    Registriert seit:
    21. März 2014
    Beiträge:
    295
    Ort:
    Bürostuhl
    Minecraft:
    GPSforLEGENDS
    #2