Skip to content

Commit

Permalink
1.6.6.1 RELEASE,
Browse files Browse the repository at this point in the history
* Bug where packetevents won't enable if ProtocolLib isn't present FIXED
  • Loading branch information
retrooper committed Sep 9, 2020
1 parent 787df36 commit 4d42a23
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.6.6</version>
<version>1.6.6.1</version>

<!-- You can build the project with this: "mvn clean compile assembly:single" -->
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.github.retrooper.packetevents.event.PacketEvent;
import io.github.retrooper.packetevents.event.PacketListener;
import io.github.retrooper.packetevents.utils.protocollib.ProtocolLibListener;
import io.github.retrooper.packetevents.utils.protocollib.ProtocolLibUtils;
import org.bukkit.Bukkit;

import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -108,10 +109,6 @@ public void run() {
}

public void registerListener(final PacketListener listener) {
if (ProtocolLibListener.isProtocolLibPresent() == ProtocolLibListener.ProtocolLibPresent.UNKNOWN) {
ProtocolLibListener.load();
}

final List<Method> methods = new ArrayList<Method>();
for (final Method m : listener.getClass().getDeclaredMethods()) {
if (m.isAnnotationPresent(PacketHandler.class)
Expand All @@ -121,7 +118,7 @@ public void registerListener(final PacketListener listener) {
}

if (!methods.isEmpty()) {
if (ProtocolLibListener.isProtocolLibPresent() == ProtocolLibListener.ProtocolLibPresent.PRESENT) {
if (ProtocolLibUtils.isAvailable()) {
ProtocolLibListener.registerProtocolLibListener(listener, methods);
} else {
registeredMethods.put(listener, methods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,9 @@
import java.util.List;

public class ProtocolLibListener {
public enum ProtocolLibPresent {
UNKNOWN, NOT_PRESENT, PRESENT
}

private static ProtocolLibPresent plibPresent = ProtocolLibPresent.UNKNOWN;


public static void load() {
if (ProtocolLibUtils.isAvailable()) {
plibPresent = ProtocolLibPresent.PRESENT;
}
}

public static ProtocolLibPresent isProtocolLibPresent() {
return plibPresent;
}

public static void registerProtocolLibListener(PacketListener listener, List<Method> methods) {
if (plibPresent == ProtocolLibPresent.PRESENT) {
if (ProtocolLibUtils.isAvailable()) {
for (Method m : methods) {
if (m.getParameterTypes()[0].equals(PacketReceiveEvent.class)) {
PacketHandler annot = m.getAnnotation(PacketHandler.class);
Expand Down

0 comments on commit 4d42a23

Please sign in to comment.