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

ProtocolLib is not loaded or initialized properly. #3339

Open
4 tasks done
Nicolol1234 opened this issue Jan 1, 2025 · 1 comment
Open
4 tasks done

ProtocolLib is not loaded or initialized properly. #3339

Nicolol1234 opened this issue Jan 1, 2025 · 1 comment

Comments

@Nicolol1234
Copy link

Nicolol1234 commented Jan 1, 2025

Make sure you're doing the following

  • You're using the latest build for your server version
  • This isn't an issue caused by another plugin
  • You've checked for duplicate issues
  • You didn't use /reload

Describe the question
Hi, i'm currently trying to use protocollib as a dependency for my plugin, but when i try to use it, i get this error:

java.lang.IllegalStateException: ProtocolLib is not loaded or initialized properly.```

**API method(s) used**
ProtocolManager, PacketContainer, WrappedDataWatcher

**Expected behavior**
For it to uhh well work

**Code**
In the onEnable:
```java
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
        AssignTeam.initialize(new GlowAllies(protocolManager), CreateTeams.redTeam, CreateTeams.blueTeam, CreateTeams.spectatorTeam);

and

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import org.bukkit.entity.Player;

public class GlowAllies {
    private final ProtocolManager protocolManager;

    public GlowAllies(ProtocolManager protocolManager) {
        this.protocolManager = protocolManager;
    }

    public void setGlow(Player player, Player receiver) {
        PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
        packet.getIntegers().write(0, player.getEntityId()); // Set packet's entity id
        WrappedDataWatcher watcher = new WrappedDataWatcher(); // Create data watcher, the Entity Metadata packet requires this
        WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class); // Found this through google, needed for some stupid reason
        watcher.setEntity(player); // Set the new data watcher's target
        watcher.setObject(0, (byte) (0x40)); // Set status to glowing, found on protocol page
        packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); // Make the packet's datawatcher the one we created
        protocolManager.sendServerPacket(receiver, packet);
    }
}

Additional context
I'm trying to make a certain player glow to another specific player, i searched on the internet and found the 2dn block of code, but i can't even seem to make protocolLib to load (the error above). It may be a skill issue since i'm new to coding, but i don't understand what's the problem here...

@Nicolol1234
Copy link
Author

shit i broke the formatting

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

1 participant