How can I get the command which is in an command block? I've tried casting to ComandBlock and toher things but a can't figure out how to to it. Block -> Command in that block, if it is and command block ?
What about repeating and chain command block? It works for normal Command blocks. The error message: It cannot cast org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja va:310) ~[spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav a:62) ~[spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j ava:502) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j ava:487) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at org.bukkit.craftbukkit.v1_9_R1.event.CraftEventFactory.callPlayerInte ractEvent(CraftEventFactory.java:231) [spigot-1.9.2.jar:git-Spigot-e000104-4cb32 58] at net.minecraft.server.v1_9_R1.PlayerInteractManager.a(PlayerInteractMa nager.java:482) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java :888) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.PacketPlayInUseItem.a(SourceFile:55) [sp igot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.PacketPlayInUseItem.a(SourceFile:11) [sp igot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:1 3) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51 1) [?:1.8.0_73] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_73] at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot-1.9 .2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:7 21) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:4 00) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:6 60) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java :559) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_73] Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_9_R1.block.Cr aftBlockState cannot be cast to org.bukkit.block.CommandBlock at de.simonmeusel.commanddescriptor.main.Plugin.onPlayerInteractEvent(Pl ugin.java:46) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0 _73] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:62) ~[?:1.8.0_73] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) ~[?:1.8.0_73] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_73] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja va:306) ~[spigot-1.9.2.jar:git-Spigot-e000104-4cb3258] ... 17 more
Hmm, looking at the api, if it won't cast to CommandBlock, it doesn't look like there are any block states for repeating and chain commands blocks. It might not have been implemented yet which if is the case, you may want to report the issue here https://hub.spigotmc.org/jira/secure/Dashboard.jspa . What exactly are you trying to do?
I want to create a plugin to spawn an ArmorStand with the command as name so you can make a screenshot and post it to forums.
I looked into the bug tracker a i found the bug reported and marked as resolved. The problem was i used a old spigot.jar. Solved by creating a new jar with BuildTools.