mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Don't use google commons in Util#requiresNettyChannelMetadata (#2907)
* Improve Util#requiresNettyChannelMetadata * Fix comment * Don't use google commons in Util#requiresNettyChannelMetadata
This commit is contained in:
parent
838aa3019b
commit
2a4f222c3e
@ -7,6 +7,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -345,20 +346,18 @@ public class Util {
|
|||||||
if (version == null)
|
if (version == null)
|
||||||
return REQUIRES_CHANNEL_METADATA = false;
|
return REQUIRES_CHANNEL_METADATA = false;
|
||||||
try {
|
try {
|
||||||
Integer[] parts = Iterables.toArray(
|
Integer[] parts = StreamSupport.stream(Splitter.on('.').split(version.artifactVersion()).spliterator(), false).map(string -> {
|
||||||
Iterables.transform(Splitter.on('.').split(version.artifactVersion()), string -> {
|
|
||||||
// Newer versions of netty use suffix (like .Final) that can't be parsed to Integer
|
// Newer versions of netty use suffix (like .Final) that can't be parsed to Integer
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(string);
|
return Integer.parseInt(string);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}),
|
}).toArray(Integer[]::new);
|
||||||
int.class);
|
|
||||||
int major = parts[0];
|
int major = parts[0];
|
||||||
int minor = parts[1];
|
int minor = parts[1];
|
||||||
int patch = parts[2];
|
int patch = parts[2];
|
||||||
return REQUIRES_CHANNEL_METADATA = major >= 5 || major == 4 && minor > 1 || patch >= 64;
|
return REQUIRES_CHANNEL_METADATA = major >= 5 || major == 4 && (minor > 1 || patch >= 64);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
return REQUIRES_CHANNEL_METADATA = true;
|
return REQUIRES_CHANNEL_METADATA = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user