Solved protocollib ProtocolManager is null error

Discussion in 'Spigot Plugin Development' started by weedsnorkeler, Jul 9, 2021.

  1. I'm trying to use ProtocolLib but I get an error saying ProtocolManager is null. I thought it was a problem with my plugin so I created a blank one but I still get the same error. Am I right to be putting the same ProtocolLib jar I put in my server plugins into my plugins dependencies or is there some other file I need to download? I have the plugin in the servers plugins folder and I have ProtocolLib in my plugins dependencies I'm not sure what could be causing this.
     
  2. Are you using maven?
     
  3. no do i need to be? i tried to use it earlier but it just broke everything and confused me
     
  4. Can you show your code?
     
  5. this is just to test if ProtocolLib is working and i get an error saying pm is null, i just copied it from some youtube tutorial
    Code (Java):
    Player player = (Player) sender;
    Location loc = player.getTargetBlock(null,48).getLocation();

    ProtocolManager pm = ProtocolLibrary.getProtocolManager();
    PacketContainer packet = pm.createPacket(PacketType.Play.Server.EXPLOSION);

    packet.getModifier().writeDefaults();
    packet.getDoubles().write(0,loc.getX()).write(1,loc.getY()).write(2,loc.getZ());
    packet.getFloat().write(0,(float)4);

    try {
        pm.sendServerPacket(player,packet);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
     
  6. i tried setting up a test plugin with maven solely to get ProtocolLib working and i still get the same error about pm being null

    this is my pom.xml
    Code (XML):
    <?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>org.example</groupId>
        <artifactId>ProtocolTest</artifactId>
        <version>1.0-SNAPSHOT</version>

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

        <repositories>
            <repository>
                <id>spigot-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
            <repository>
                <id>dmulloy2-repo</id>
                <url>https://repo.dmulloy2.net/repository/public/</url>
            </repository>
        </repositories>

        <dependencies>
            <dependency>
                <groupId>com.comphenix.protocol</groupId>
                <artifactId>ProtocolLib</artifactId>
                <version>4.7.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.17-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>

    </project>
    still have depend: [ProtocolLib] in my plugin.yml, am i doing something wrong?
     
  7. bump ive been trying to debug this for like a day could it be my computer?? ive tried like 4 different versions and have made like 2 separate servers and test plugins i am so lost
     
  8. You forgot add scope>provided</scope> for ProtocolLib
     
    • Like Like x 1
  9. thank you so much that was exactly what it was