ProtocolLib is not loaded or initialized properly.
Nicolol1234 opened this issue ยท 1 comments
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...