[BLEEDING] Allow ProtocolLib 3.7 and disable SoundDistance on MC 1.9.

This commit is contained in:
asofold 2016-03-02 19:49:02 +01:00
parent 3c3ae4b351
commit 9be2cd2400
3 changed files with 47 additions and 14 deletions

View File

@ -80,7 +80,12 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload, Joi
// (Set lastKeepAlive if this or fight.godmode is enabled.)
register("fr.neatmonster.nocheatplus.checks.net.protocollib.KeepAliveAdapter", plugin);
}
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
if (ServerVersion.compareMinecraftVersion("1.9") >= 0) {
// Don't use this listener.
// TODO: Add module for ProtocolLib 3.7 ?
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().info(Streams.STATUS, "Disable SoundDistance due to incompatibilities.");
}
else if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
register("fr.neatmonster.nocheatplus.checks.net.protocollib.SoundDistance", plugin);
}
if (!registeredPacketAdapters.isEmpty()) {

View File

@ -90,7 +90,7 @@ public class GenericVersion {
* @param suffix
* @return
*/
protected static String parseVersionDelimiters(String input, String prefix, String suffix) {
public static String parseVersionDelimiters(String input, String prefix, String suffix) {
int preIndex = prefix.isEmpty() ? 0 : input.indexOf(prefix);
if (preIndex != -1) {
String candidate = input.substring(preIndex + prefix.length());
@ -111,7 +111,7 @@ public class GenericVersion {
* @param beginIndex
* @return null if not successful.
*/
protected static String collectVersion(String input, int beginIndex) {
public static String collectVersion(String input, int beginIndex) {
StringBuilder buffer = new StringBuilder(128);
// Rigid scan by character.
boolean numberFound = false;

View File

@ -18,6 +18,7 @@ import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.logging.Streams;
/**
* Default factory for add-in components which might only be available under certain circumstances.
@ -63,18 +64,45 @@ public class DefaultComponentFactory {
// ProtocolLib dependencies.
Plugin pluginProtocolLib = Bukkit.getPluginManager().getPlugin("ProtocolLib");
try {
if (ServerVersion.isMinecraftVersionBetween("1.8", true, "1.9", false)
|| ServerVersion.isMinecraftVersionBetween("1.2.5", true, "1.9", false)
&& pluginProtocolLib != null && GenericVersion.compareVersions("3.6.4", pluginProtocolLib.getDescription().getVersion()) == 0) {
available.add(new ProtocolLibComponent(plugin));
} else {
if (pluginProtocolLib != null) {
StaticLog.logWarning("Can't tell if the packet level hooks are compatible to the version of ProtocolLib in use. NoCheatPlus supports ProtocolLib 3.6.4 on Minecraft 1.7.10 and earlier, and ProtocolLib 3.6.4 or later on Minecraft 1.8 (and later).");
}
StaticLog.logInfo("Packet level access: ProtocolLib is not available.");
boolean protocolLibAvailable = false;
if (pluginProtocolLib != null) {
String _pV = pluginProtocolLib.getDescription().getVersion().toLowerCase();
String pV = GenericVersion.collectVersion(_pV, 0);
if (pV == null) {
pV = GenericVersion.parseVersionDelimiters(_pV, "", "-snapshot");
}
if (pV == null) {
}
else {
try {
boolean vP1 = GenericVersion.compareVersions("3.6.4", pV) == 0;
boolean vP2 = GenericVersion.compareVersions("3.6.5", pV) == 0;
boolean vP3 = GenericVersion.compareVersions("3.7", pV) == 0;
if (
ServerVersion.isMinecraftVersionBetween("1.9", true, "2.0", false)
&& vP3
|| ServerVersion.isMinecraftVersionBetween("1.8", true, "1.9", false)
&&
(vP1 || vP2)
|| ServerVersion.isMinecraftVersionBetween("1.2.5", true, "1.9", false)
&& vP1
) {
available.add(new ProtocolLibComponent(plugin));
protocolLibAvailable = true;
}
} catch (Throwable t){
StaticLog.logWarning("Failed to set up packet level hooks.");
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.LOGGING_EXTENDED_STATUS)) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.INIT, t);
}
}
}
}
if (!protocolLibAvailable) {
if (pluginProtocolLib != null) {
StaticLog.logWarning("NoCheatPlus supports ProtocolLib 3.6.4 on Minecraft 1.7.10 and earlier, ProtocolLib 3.6.4 or 3.6.5 on Minecraft 1.8, ProtocolLib 3.7 on Minecraft 1.9 [EXPERIMENTAL].");
}
} catch (Throwable t){
StaticLog.logInfo("Packet level access: ProtocolLib is not available.");
}