diff --git a/ProtocolLib/pom.xml b/ProtocolLib/pom.xml
index 1e832648..e88b3005 100644
--- a/ProtocolLib/pom.xml
+++ b/ProtocolLib/pom.xml
@@ -91,6 +91,23 @@
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.12.4
+
+ ${basedir}/target/server/
+ -Xmx1024m -Xms1024M -Dnojline=true
+
+
+
+
+ integration-test
+ verify
+
+
+
+
@@ -146,7 +163,7 @@
-
+
org.apache.maven.plugins
maven-gpg-plugin
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
index a61db9b7..a48c2302 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java
@@ -126,7 +126,7 @@ public class ProtocolLibrary extends JavaPlugin {
// Updater
private Updater updater;
- private boolean updateDisabled;
+ private static boolean UPDATES_DISABLED;
// Logger
private Logger logger;
@@ -479,7 +479,7 @@ public class ProtocolLibrary extends JavaPlugin {
manager.sendProcessedPackets(tickCounter++, true);
// Check for updates too
- if (!updateDisabled) {
+ if (!UPDATES_DISABLED) {
checkUpdates();
}
}
@@ -511,7 +511,7 @@ public class ProtocolLibrary extends JavaPlugin {
}
} catch (Exception e) {
reporter.reportDetailed(this, Report.newBuilder(REPORT_CANNOT_UPDATE_PLUGIN).error(e));
- updateDisabled = true;
+ UPDATES_DISABLED = true;
}
}
diff --git a/ProtocolLib/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java b/ProtocolLib/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java
new file mode 100644
index 00000000..07e57a01
--- /dev/null
+++ b/ProtocolLib/src/test/java/com/comphenix/integration/protocol/SimpleCraftBukkitITCase.java
@@ -0,0 +1,119 @@
+package com.comphenix.integration.protocol;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import org.apache.commons.io.FileUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.PluginLoadOrder;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.reflect.FieldUtils;
+import com.google.common.collect.Lists;
+
+// Damn final classes ...
+@RunWith(org.powermock.modules.junit4.PowerMockRunner.class)
+@PrepareForTest(PluginDescriptionFile.class)
+public class SimpleCraftBukkitITCase {
+ // The fake plugin
+ private static volatile Plugin FAKE_PLUGIN = null;
+
+ /**
+ * Setup the CraftBukkit server for all the tests.
+ * @throws IOException Unable to setup server.
+ * @throws InterruptedException Thread interrupted.
+ */
+ @BeforeClass
+ public static void setupCraftBukkit() throws Exception {
+ setupPlugins();
+ org.bukkit.craftbukkit.Main.main(new String[0]);
+
+ // We need to wait until the server object is ready
+ while (Bukkit.getServer() == null)
+ Thread.sleep(1);
+
+ // Make it clear this plugin doesn't exist
+ FAKE_PLUGIN = createPlugin("FakeTestPluginIntegration");
+
+ // No need to look for updates
+ FieldUtils.writeStaticField(ProtocolLibrary.class, "UPDATES_DISABLED", Boolean.TRUE, true);
+
+ // Wait until the server and all the plugins have loaded
+ Bukkit.getScheduler().callSyncMethod(FAKE_PLUGIN, new Callable