Cannot invoke "com.xxmicloxx.NoteBlockAPI.NoteBlockAPI.doAsync(java.lang.Runnable)" because "this.plugin" is null
Full error:
[21:04:12 ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'MooSussyPlayMusicInCowSaysGamePluginByCowGL-1.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException: Cannot invoke "com.xxmicloxx.NoteBlockAPI.NoteBlockAPI.doAsync(java.lang.Runnable)" because "this.plugin" is null
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:127) ~[purpur-1.20.jar:git-Purpur-1990]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:35) ~[purpur-1.20.jar:git-Purpur-1990]
at io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy.loadProviders(ModernPluginLoadingStrategy.java:116) ~[purpur-1.20.jar:git-Purpur-1990]
at io.papermc.paper.plugin.storage.SimpleProviderStorage.enter(SimpleProviderStorage.java:39) ~[purpur-1.20.jar:git-Purpur-1990]
at io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enter(LaunchEntryPointHandler.java:36) ~[purpur-1.20.jar:git-Purpur-1990]
at org.bukkit.craftbukkit.v1_20_R1.CraftServer.loadPlugins(CraftServer.java:445) ~[purpur-1.20.jar:git-Purpur-1990]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:307) ~[purpur-1.20.jar:git-Purpur-1990]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1117) ~[purpur-1.20.jar:git-Purpur-1990]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[purpur-1.20.jar:git-Purpur-1990]
at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "com.xxmicloxx.NoteBlockAPI.NoteBlockAPI.doAsync(java.lang.Runnable)" because "this.plugin" is null
at com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer.start(SongPlayer.java:312) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer.<init>(SongPlayer.java:98) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer.<init>(SongPlayer.java:75) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer.<init>(SongPlayer.java:59) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at com.xxmicloxx.NoteBlockAPI.songplayer.RangeSongPlayer.<init>(RangeSongPlayer.java:22) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at com.xxmicloxx.NoteBlockAPI.songplayer.PositionSongPlayer.<init>(PositionSongPlayer.java:25) ~[NoteBlockAPI-1.6.2-SNAPSHOT.jar:?]
at xyz.cowgl.moosussyplaymusicincowsaysgamepluginbycowgl.MooSussyPlayMusicInCowSaysGamePluginByCowGL.<init>(MooSussyPlayMusicInCowSaysGamePluginByCowGL.java:20) ~[MooSussyPlayMusicInCowSaysGamePluginByCowGL-1.0.jar:?]
at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ~[?:?]
at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:304) ~[?:?]
at java.lang.Class.newInstance(Class.java:725) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:88) ~[purpur-api-1.20-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[purpur-1.20.jar:git-Purpur-1990]
... 9 more
Hi! It looks like NoteBlockAPI is not initialized or running. That is most commonly caused by shading. Make sure that you are not shading the NoteBlockAPI in your pom or build.gradle file. Also I assume that you added the NoteBlockAPI as depend or softdepend in your plugin.yml.
I'm not shading it, and yes, I add the API to depend.
Would you show me your pom or build.gradle file?
Would you show me your pom or build.gradle file?
Sure.
<?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>xyz.cowgl</groupId>
<artifactId>MooSussyPlayMusicInCowSaysGamePluginByCowGL</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>MooSussyPlayMusicInCowSaysGamePluginByCowGL</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</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>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.koca2000</groupId>
<artifactId>NoteBlockAPI</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Any updates on this?
I just found where the problem is. It's because I'm not creating the player in onEnable.