mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-29 23:17:41 +02:00
Also detect v123.5 for plugin versions.
This commit is contained in:
parent
b6fa205508
commit
acca3244a8
@ -23,6 +23,21 @@ import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
|||||||
*/
|
*/
|
||||||
public class Activation implements IDescriptiveActivation {
|
public class Activation implements IDescriptiveActivation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find delimiters on the right side.
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* Lower case expected.
|
||||||
|
* @return null on failures.
|
||||||
|
*/
|
||||||
|
private static final String rightSideDelimiters(final String version) {
|
||||||
|
String pV = GenericVersion.parseVersionDelimiters(version, "", "-snapshot");
|
||||||
|
if (pV == null) {
|
||||||
|
pV = GenericVersion.parseVersionDelimiters(version, "", "-b");
|
||||||
|
}
|
||||||
|
return pV;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This attempt to transform/parse the plugin version such that the result
|
* This attempt to transform/parse the plugin version such that the result
|
||||||
* can be used for comparison with a server version. The plugin is fetched
|
* can be used for comparison with a server version. The plugin is fetched
|
||||||
@ -34,13 +49,13 @@ public class Activation implements IDescriptiveActivation {
|
|||||||
public static String guessUsablePluginVersion(String pluginName) {
|
public static String guessUsablePluginVersion(String pluginName) {
|
||||||
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||||
final String version = plugin.getDescription().getVersion().toLowerCase();
|
final String version = plugin.getDescription().getVersion().toLowerCase();
|
||||||
|
// Assume ordinary start.
|
||||||
String pV = GenericVersion.collectVersion(version, 0);
|
String pV = GenericVersion.collectVersion(version, 0);
|
||||||
|
// Right hand side delimiters.
|
||||||
if (pV == null) {
|
if (pV == null) {
|
||||||
pV = GenericVersion.parseVersionDelimiters(version, "", "-snapshot");
|
pV = rightSideDelimiters(version);
|
||||||
}
|
|
||||||
if (pV == null) {
|
|
||||||
pV = GenericVersion.parseVersionDelimiters(version, "", "-b");
|
|
||||||
}
|
}
|
||||||
|
// Try skipping initial characters like in "v1.0".
|
||||||
if (pV == null) {
|
if (pV == null) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < version.length() && !Character.isDigit(version.charAt(i))) {
|
while (i < version.length() && !Character.isDigit(version.charAt(i))) {
|
||||||
@ -48,8 +63,9 @@ public class Activation implements IDescriptiveActivation {
|
|||||||
}
|
}
|
||||||
if (i < version.length()) {
|
if (i < version.length()) {
|
||||||
pV = GenericVersion.collectVersion(version, i);
|
pV = GenericVersion.collectVersion(version, i);
|
||||||
|
// Right hand side delimiters.
|
||||||
if (pV == null) {
|
if (pV == null) {
|
||||||
// TODO: Consider find something in the end as delimiter.
|
pV = rightSideDelimiters(version.substring(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user