Archiviert
13
0

Make async packets less scary

Dieser Commit ist enthalten in:
Dan Mulloy 2015-03-22 15:26:01 -04:00
Ursprung 923f4f4c4a
Commit 37123c0aa1
3 geänderte Dateien mit 16 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -404,7 +404,6 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
* @return TRUE if it does, FALSE otherwise. * @return TRUE if it does, FALSE otherwise.
*/ */
public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException { public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException {
if (isMinecraftAsync == null && !alwaysSync) { if (isMinecraftAsync == null && !alwaysSync) {
try { try {
isMinecraftAsync = FuzzyReflection.fromClass(MinecraftReflection.getPacketClass()).getMethodByName("a_.*"); isMinecraftAsync = FuzzyReflection.fromClass(MinecraftReflection.getPacketClass()).getMethodByName("a_.*");
@ -419,7 +418,7 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
} else if (methods.size() == 1) { } else if (methods.size() == 1) {
// We're in 1.2.5 // We're in 1.2.5
alwaysSync = true; alwaysSync = true;
} else if (MinecraftVersion.getCurrentVersion().equals(MinecraftVersion.BOUNTIFUL_UPDATE)) { } else if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BOUNTIFUL_UPDATE)) {
// The centralized async marker was removed in 1.8 // The centralized async marker was removed in 1.8
// Incoming chat packets can be async // Incoming chat packets can be async
if (event.getPacketType() == PacketType.Play.Client.CHAT) { if (event.getPacketType() == PacketType.Play.Client.CHAT) {
@ -436,7 +435,8 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
return false; return false;
} }
} else { } else {
ProtocolLibrary.log(Level.WARNING, "Cannot determine asynchronous state of packets!"); ProtocolLibrary.log(Level.INFO, "Could not determine asynchronous state of packets.");
ProtocolLibrary.log(Level.INFO, "This can probably be ignored.");
alwaysSync = true; alwaysSync = true;
} }
} }

Datei anzeigen

@ -17,6 +17,7 @@ import com.google.common.collect.Lists;
* *
* @author Kristian * @author Kristian
*/ */
@SuppressWarnings("unused") // Java 8 compat
public abstract class MethodInfo implements GenericDeclaration, Member { public abstract class MethodInfo implements GenericDeclaration, Member {
/** /**
* Wraps a method as a MethodInfo object. * Wraps a method as a MethodInfo object.

Datei anzeigen

@ -256,6 +256,13 @@ public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializa
result(); result();
} }
public boolean isAtLeast(MinecraftVersion other) {
if (other == null)
return false;
return compareTo(other) >= 0;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) if (obj == null)