+ * This is useful if a server operator has tested and verified that a version of ProtocolLib works,
+ * but doesn't want or can't upgrade to a newer version.
+ *
+ * @param ignoreVersion - the version of Minecraft where the satefy will be disabled.
+ */
+ public void setIgnoreVersionCheck(String ignoreVersion) {
+ global.set(IGNORE_VERSION_CHECK, ignoreVersion);
+ }
/**
* Retrieve whether or not metrics is enabled.
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
index e3f8e09d..2f5b4774 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
@@ -19,6 +19,7 @@ package com.comphenix.protocol;
import java.io.IOException;
import java.util.logging.Handler;
+import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
@@ -43,6 +44,15 @@ import com.comphenix.protocol.reflect.compiler.BackgroundCompiler;
* @author Kristian
*/
public class ProtocolLibrary extends JavaPlugin {
+ /**
+ * The minimum version ProtocolLib has been tested with.
+ */
+ private static final String MINIMUM_MINECRAFT_VERSION = "1.0.0";
+
+ /**
+ * The maximum version ProtocolLib has been tested with,
+ */
+ private static final String MAXIMUM_MINECRAFT_VERSION = "1.4.5";
/**
* The number of milliseconds per second.
@@ -120,7 +130,7 @@ public class ProtocolLibrary extends JavaPlugin {
commandPacket = new CommandPacket(detailedReporter, this, logger, protocolManager);
// Send logging information to player listeners too
- broadcastUsers(PERMISSION_INFO);
+ setupBroadcastUsers(PERMISSION_INFO);
} catch (Throwable e) {
detailedReporter.reportDetailed(this, "Cannot load ProtocolLib.", e, protocolManager);
@@ -142,7 +152,7 @@ public class ProtocolLibrary extends JavaPlugin {
}
}
- private void broadcastUsers(final String permission) {
+ private void setupBroadcastUsers(final String permission) {
// Guard against multiple calls
if (redirectHandler != null)
return;
@@ -151,7 +161,10 @@ public class ProtocolLibrary extends JavaPlugin {
redirectHandler = new Handler() {
@Override
public void publish(LogRecord record) {
- commandPacket.broadcastMessageSilently(record.getMessage(), permission);
+ // Only display warnings and above
+ if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
+ commandPacket.broadcastMessageSilently(record.getMessage(), permission);
+ }
}
@Override
@@ -188,13 +201,13 @@ public class ProtocolLibrary extends JavaPlugin {
logger.info("Structure compiler thread has been disabled.");
}
+ // Handle unexpected Minecraft versions
+ verifyMinecraftVersion();
+
// Set up command handlers
registerCommand(CommandProtocol.NAME, commandProtocol);
registerCommand(CommandPacket.NAME, commandPacket);
- // Notify server managers of incompatible plugins
- checkForIncompatibility(manager);
-
// Player login and logout events
protocolManager.registerEvents(manager, this);
@@ -220,6 +233,26 @@ public class ProtocolLibrary extends JavaPlugin {
}
}
+ // Used to check Minecraft version
+ private void verifyMinecraftVersion() {
+ try {
+ MinecraftVersion minimum = new MinecraftVersion(MINIMUM_MINECRAFT_VERSION);
+ MinecraftVersion maximum = new MinecraftVersion(MAXIMUM_MINECRAFT_VERSION);
+ MinecraftVersion current = new MinecraftVersion(getServer());
+
+ // Skip certain versions
+ if (!config.getIgnoreVersionCheck().equals(current.getVersion())) {
+ // We'll just warn the user for now
+ if (current.compareTo(minimum) < 0)
+ logger.warning("Version " + current + " is lower than the minimum " + minimum);
+ if (current.compareTo(maximum) > 0)
+ logger.warning("Version " + current + " has not yet been tested! Proceed with caution.");
+ }
+ } catch (Exception e) {
+ reporter.reportWarning(this, "Unable to retrieve current Minecraft version.", e);
+ }
+ }
+
private void registerCommand(String name, CommandExecutor executor) {
try {
if (executor == null)
@@ -296,18 +329,6 @@ public class ProtocolLibrary extends JavaPlugin {
}
}
- private void checkForIncompatibility(PluginManager manager) {
- // Plugin authors: Notify me to remove these
- String[] incompatiblePlugins = {};
-
- for (String plugin : incompatiblePlugins) {
- if (manager.getPlugin(plugin) != null) {
- // Check for versions, ect.
- reporter.reportWarning(this, "Detected incompatible plugin: " + plugin);
- }
- }
- }
-
@Override
public void onDisable() {
// Disable compiler
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java
index f37511f8..cefd8a0a 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java
@@ -242,7 +242,7 @@ public class AsyncListenerHandler {
final AsyncRunnable listenerLoop = getListenerLoop();
- filterManager.getScheduler().scheduleAsyncDelayedTask(listener.getPlugin(), new Runnable() {
+ scheduleAsync(new Runnable() {
@Override
public void run() {
Thread thread = Thread.currentThread();
@@ -290,7 +290,7 @@ public class AsyncListenerHandler {
final AsyncRunnable listenerLoop = getListenerLoop();
final Function
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java
index 7b6b038b..5b0e6a1c 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java
@@ -25,13 +25,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import net.minecraft.server.Packet;
-
import com.comphenix.protocol.PacketStream;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.PrioritizedListener;
import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.FuzzyReflection;
+import com.comphenix.protocol.utility.MinecraftReflection;
import com.google.common.primitives.Longs;
/**
@@ -403,10 +402,10 @@ public class AsyncMarker implements Serializable, Comparable