1.16.5 Command Panels api doesn't work

Discussion in 'Spigot Plugin Development' started by CoderBoyo, Jun 14, 2021.

  1. I wasn't sure what thread to put this in so i just put it here.
    So when using the command panels api :ihttps://www.spigotmc.org/resources/command-panels-custom-guis.67788/, https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki/developer-api
    I get this error:
    Code (Text):
    Could not pass event InventoryClickEvent to MegaSurvival v1
    org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2436) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:28) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(SourceFile:144) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(SourceFile:118) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1061) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1054) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(SourceFile:127) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1038) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:970) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at java.lang.Thread.run(Thread.java:831) [?:?]
    Caused by: java.lang.ClassCastException: Cannot cast net.ultibuild.main.Main to me.rockyhawk.commandpanels.CommandPanels
        at java.lang.Class.cast(Class.java:3818) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.getPlugin(JavaPlugin.java:397) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        at me.rockyhawk.commandpanels.CommandPanels.getAPI(CommandPanels.java:253) ~[?:?]
        at net.ultibuild.main.Main.OnInvAction(Main.java:71) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
        ... 18 more

    This is line 71:
    Code (Text):
            CommandPanelsAPI api = CommandPanels.getAPI();
    Now CommandPanels extends JavaPlugin and i think its somehow thinking that the CommandPanels thingy is my plugin, I'm really not sure please help if you can!

    (Note I use CommandPanelsAPI in everything so it practically renders my plugin useless)
     
  2. Post your entire class.
     
  3. How are you building your plugin? Maven?
     
  4. Yes
     
  5. I'm afraid I can't do that as it would contain info for a to be public server that is not ment to be distributed
     
  6. Did you set the dependency as provided?
     
  7. Pretty sure but I will double check
     
  8. Alright
    It seems to me your plugin is loading the other plugin's main class.
    It usually happens when the other plugin is included in the jar (not marked as provided).
     
  9. That might be the case as when I open the jar I see plenty of things that I didn't make
     
  10. Let me see your pom.xml
     
  11. Can you send your pom.xml and plugin.yml?
     
  12. Code (Text):
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>groupId</groupId>
        <artifactId>MegaSurvival</artifactId>
        <version>1.0-SNAPSHOT</version>

        <properties>
            <maven.compiler.source>15</maven.compiler.source>
            <maven.compiler.target>15</maven.compiler.target>
        </properties>

        <repositories>
            <repository>
                <id>fren_gor</id>
                <url>https://nexus.frengor.com/repository/public/</url>
            </repository>
        </repositories>

        <dependencies>
            <dependency>
                <groupId>com.frengor</groupId>
                <artifactId>inventorymanagementplugin</artifactId>
                <version>1.0-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
       
    </project>
     
  13. It seems you are not 100% building with Maven.
    Don't use the "Hammer" to build.
    Click on Maven (top-right corner of the screen), then Cycles (or something), package. Your jar will be generated on the /target folder.


    And you need Spigot's API as dependency in your pom too.
     
    • Agree Agree x 1
  14. sorry I'm a bit confused what do you mean?
     
  15. That "Hammer" on IntelliJ doesn't use Maven.

    Follow these steps to build with maven:
    Click on Maven (top-right corner of the screen), then Cycles (or something), package. Your jar will be generated on the /target folder.