Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot invoke "com.xxmicloxx.NoteBlockAPI.NoteBlockAPI.doAsync(java.lang.Runnable)" because "this.plugin" is null #104

Closed
charlie-moomoo opened this issue Apr 28, 2024 · 6 comments

Comments

@charlie-moomoo
Copy link

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
@koca2000
Copy link
Owner

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.

@charlie-moomoo
Copy link
Author

I'm not shading it, and yes, I add the API to depend.

@koca2000
Copy link
Owner

koca2000 commented May 2, 2024

Would you show me your pom or build.gradle file?

@charlie-moomoo
Copy link
Author

Would you show me your pom or build.gradle file?

Sure.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0"
         xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://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>

@charlie-moomoo
Copy link
Author

Any updates on this?

@charlie-moomoo
Copy link
Author

I just found where the problem is. It's because I'm not creating the player in onEnable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants