Solved Error PlayerMoveEvent

Discussion in 'Plugin Development' started by DeadInside, Dec 5, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    DeadInside

    So I am new to coding and I tried a JumpNRun Plugin and Ive always get this error. Theres no effect on Gold block or even when I try to rightclick the finish sign.

    Heres the Error:

    Error (open)
    Code:
    [12:34:35 ERROR]: Could not pass event PlayerMoveEvent to Enojump v0.1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:255) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketPlayInFlying.a(SourceFile:126) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketPlayInPositionLook.a(SourceFile:18) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
            at java.base/java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            at java.base/java.lang.Thread.run(Unknown Source) [?:?]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R1.block.CraftBlock cannot be cast to jdk.scripting.nashorn/jdk.nashorn.internal.ir.Block
            at classes.Listeners.onPlayerMove(Listeners.java:144) ~[?:?]
            at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?]
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
            at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
            ... 14 more


    Heres the Code and the line where the Error appears.

    Original Code (open)
    Code:
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent event) {
            this.event = event;
            if(plugin.inJump.contains(event.getPlayer().getName())) {
                Player player = event.getPlayer();
    
    
                Block block = (Block) player.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
    
                if(((org.bukkit.block.Block) block).getType() == Material.GOLD_BLOCK) {
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20*5, 3));
                    player.playSound(player.getLocation(), Sound.GHAST_SCREAM, 3, 2);
                }
                if(((org.bukkit.block.Block) block).getType() == Material.BEDROCK) {
                    teleportToSpawn(player);
                }
            }
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @DeadInside Remove the Block import and try again.
     
  3. Offline

    DeadInside

    Do you mean this one?
    Just to make sure
    Code:
    import jdk.nashorn.internal.ir.Block;
     
  4. Offline

    timtower Administrator Administrator Moderator

    Yes, you are casting a Bukkit Block to that, that doesn't work.
     
  5. Offline

    DeadInside

    Okay just did it and cant export now what do I do with that now?

    Code:
                Block block = (Block) player.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
    and also:
    I get this Error:
    Code:
    Error:java: invalid source release: 12
     
  6. Offline

    timtower Administrator Administrator Moderator

    And why doesn't it allow you to export?
    That invalid source is new to me.
     
  7. Offline

    DeadInside

    Oh okay got it it was my fault but now theres this errors:

    Code:
    Error:(145, 13) java: cannot find symbol
      symbol:   class Block
      location: class classes.Listeners
    and
    Code:
    Error:(145, 28) java: cannot find symbol
      symbol:   class Block
      location: class classes.Listeners
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    DeadInside

    The block I had before
    Okay it was my fault thank you. :)

    Theres just one last question cause I dont wanna make like hundreds of posts like there no Error but when I get into the Arena my inventory wont get cleared and when I click the sign he wont teleport me to the last loc and wont give me 2 diamonds.

    Code:
        @EventHandler
        public void onSignInteract(PlayerInteractEvent event) {
            Player p = event.getPlayer();
            if(plugin.inJump.contains(p.getName())) {
                if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    if(event.getClickedBlock().getState() instanceof Sign) {
                        Sign s = (Sign) event.getClickedBlock().getState();
    
                        if(s.getLine(0).equalsIgnoreCase("§b§oEnojump")) {
                            if(s.getLine(1).equalsIgnoreCase("§4§lZiel")) {
    
                                plugin.inJump.remove(p.getName());
    
                                p.getInventory().clear();
                                ItemStack[] old = plugin.oldItems.get(p.getName());
                                p.getInventory().setContents(old);
                                p.updateInventory();
    
                                Location loc = plugin.oldLoc.get(p.getName());
                                p.teleport(loc);
    
                                p.sendMessage(plugin.prefix + "§8Du bekommst 2 Diamanten weil du es geschafft hast!");
                                p.getInventory().addItem(new ItemStack(Material.DIAMOND, 2));
                            }
                        }
                    }
                }
            }
        }
     
  10. Offline

    timtower Administrator Administrator Moderator

    @DeadInside Check which if statement is not giving true as result.
     
  11. Offline

    DeadInside

    One quick question how do I do this? Sorry but Im new and try to learn. I just googled how to check but theres no real thing online where I can check the if statements.
     
  12. Offline

    timtower Administrator Administrator Moderator

  13. Offline

    DeadInside

    I tried it but I dont get it... Fr like I make everything false i think :D
     
  14. Offline

    timtower Administrator Administrator Moderator

    What code did you use to debug?
     
  15. Offline

    DeadInside

    Okay I got it thank you for your help. :)
     
    Last edited: Dec 5, 2018
Thread Status:
Not open for further replies.

Share This Page