aikar/commands

Plugin attempted to register my.plugin.package.acf.ACFBukkitListener@6588a59a while not enabled

Timtendo12 opened this issue · 1 comments

Hi! Im trying to implement ACF in my new plugin but somehow the sharding fails? Or it tries to load it before its enabled.

StackTrace:

[16:17:51 ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'MACE-1.0-SNAPSHOT.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Exception initializing main class `net.moonbowstudios.MACE.MACE'
	at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:106) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[paper-1.20.2.jar:git-Paper-291]
	at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:35) ~[paper-1.20.2.jar:git-Paper-291]
	at io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy.loadProviders(ModernPluginLoadingStrategy.java:116) ~[paper-1.20.2.jar:git-Paper-291]
	at io.papermc.paper.plugin.storage.SimpleProviderStorage.enter(SimpleProviderStorage.java:39) ~[paper-1.20.2.jar:git-Paper-291]
	at io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enter(LaunchEntryPointHandler.java:36) ~[paper-1.20.2.jar:git-Paper-291]
	at org.bukkit.craftbukkit.v1_20_R2.CraftServer.loadPlugins(CraftServer.java:514) ~[paper-1.20.2.jar:git-Paper-291]
	at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:273) ~[paper-1.20.2.jar:git-Paper-291]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1086) ~[paper-1.20.2.jar:git-Paper-291]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-291]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.reflect.InvocationTargetException
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:98) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	... 10 more
Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register net.moonbowstudios.MACE.acf.ACFBukkitListener@6588a59a while not enabled
	at io.papermc.paper.plugin.manager.PaperEventManager.registerEvents(PaperEventManager.java:80) ~[paper-1.20.2.jar:git-Paper-291]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.registerEvents(PaperPluginManagerImpl.java:131) ~[paper-1.20.2.jar:git-Paper-291]
	at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:670) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at net.moonbowstudios.MACE.acf.BukkitCommandManager.<init>(BukkitCommandManager.java:128) ~[MACE-1.0-SNAPSHOT.jar:?]
	at net.moonbowstudios.MACE.acf.PaperCommandManager.<init>(PaperCommandManager.java:35) ~[MACE-1.0-SNAPSHOT.jar:?]
	at net.moonbowstudios.MACE.MACE.<init>(MACE.java:33) ~[MACE-1.0-SNAPSHOT.jar:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:98) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	... 10 more

Pom.xml build section

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>9</source>
                    <target>9</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.1</version>
                <configuration>
                    <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                    <relocations>
                        <relocation>
                            <pattern>co.aikar.commands</pattern>
                            <shadedPattern>net.moonbowstudios.MACE.acf</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>co.aikar.locales</pattern>
                            <shadedPattern>net.moonbowstudios.MACE.locales</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <finalName>MACE-${project.version}</finalName>
                    <outputDirectory>C:\TestServers\1.20\plugins</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

image

The MACE class is my main class.

Nvm. I got it working. I accidently passed the command Manager in the constructor and it was final.

	public MACE() {
		this.commandManager = new PaperCommandManager(this);
	}