mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
remove use of legacy currentMinecraftVersionArray
This commit is contained in:
parent
f82ccfa07e
commit
9d616d2fd0
4 changed files with 15 additions and 38 deletions
|
|
@ -283,15 +283,9 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
|
||||||
lore.add("§7If the player do not have the required xp level, the action will not be completable.");
|
lore.add("§7If the player do not have the required xp level, the action will not be completable.");
|
||||||
|
|
||||||
if(!this.packetManager.getCanSetInstantBuild()){
|
if(!this.packetManager.getCanSetInstantBuild()){
|
||||||
if(MinecraftVersionUtil.INSTANCE.isTooNewForSpigot()){
|
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a paper server.");
|
lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a paper server.");
|
||||||
lore.add("§cCurrently ProtocoLib is not detected.");
|
lore.add("§cCurrently ProtocoLib is not detected.");
|
||||||
} else {
|
|
||||||
lore.add("");
|
|
||||||
lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a newer version of this plugin for this to work.");
|
|
||||||
lore.add("§cCurrently ProtocoLib is not detected.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] loreAsArray = new String[lore.size()];
|
String[] loreAsArray = new String[lore.size()];
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,6 @@ public class UpdateUtils {
|
||||||
return Version.fromString(versionString);
|
return Version.fromString(versionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static int[] currentMinecraftVersionArray() {
|
|
||||||
String versionString = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
|
||||||
return UpdateUtils.readVersionFromString(versionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int[] readVersionFromString(String versionString) {
|
|
||||||
String[] partialVersion = versionString.split("\\.");
|
|
||||||
int[] versionParts = new int[]{0, 0, 0};
|
|
||||||
|
|
||||||
for (int i = 0; i < Math.min(3, partialVersion.length); i++) {
|
|
||||||
versionParts[i] = Integer.parseInt(partialVersion[i]);
|
|
||||||
}
|
|
||||||
return versionParts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addToStringList(FileConfiguration config, String path, String... toAdd) {
|
public static void addToStringList(FileConfiguration config, String path, String... toAdd) {
|
||||||
List<String> groups = new ArrayList<>(config.getStringList(path));
|
List<String> groups = new ArrayList<>(config.getStringList(path));
|
||||||
groups.addAll(Arrays.asList(toAdd));
|
groups.addAll(Arrays.asList(toAdd));
|
||||||
|
|
|
||||||
|
|
@ -6,29 +6,29 @@ object MinecraftVersionUtil {
|
||||||
|
|
||||||
val craftbukkitVersion: String?
|
val craftbukkitVersion: String?
|
||||||
get() {
|
get() {
|
||||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
val version = UpdateUtils.currentMinecraftVersion()
|
||||||
if (versionParts[0] != 1) return null
|
if (version.major != 1) return null
|
||||||
|
|
||||||
return when (versionParts[1]) {
|
return when (version.minor) {
|
||||||
17 -> when (versionParts[2]) {
|
17 -> when (version.patch) {
|
||||||
0, 1 -> "1_17R1"
|
0, 1 -> "1_17R1"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
18 -> when (versionParts[2]) {
|
18 -> when (version.patch) {
|
||||||
0, 1 -> "1_18R1"
|
0, 1 -> "1_18R1"
|
||||||
2 -> "1_18R2"
|
2 -> "1_18R2"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
19 -> when (versionParts[2]) {
|
19 -> when (version.patch) {
|
||||||
0, 1, 2 -> "1_19R1"
|
0, 1, 2 -> "1_19R1"
|
||||||
3 -> "1_19R2"
|
3 -> "1_19R2"
|
||||||
4 -> "1_19R3"
|
4 -> "1_19R3"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
20 -> when (versionParts[2]) {
|
20 -> when (version.patch) {
|
||||||
0, 1 -> "1_20R1"
|
0, 1 -> "1_20R1"
|
||||||
2 -> "1_20R2"
|
2 -> "1_20R2"
|
||||||
3, 4 -> "1_20R3"
|
3, 4 -> "1_20R3"
|
||||||
|
|
@ -36,7 +36,7 @@ object MinecraftVersionUtil {
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
21 -> when (versionParts[2]) {
|
21 -> when (version.patch) {
|
||||||
0, 1 -> "1_21R1"
|
0, 1 -> "1_21R1"
|
||||||
2, 3 -> "1_21R2"
|
2, 3 -> "1_21R2"
|
||||||
4 -> "1_21R3"
|
4 -> "1_21R3"
|
||||||
|
|
@ -52,8 +52,7 @@ object MinecraftVersionUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
val isTooNewForSpigot: Boolean get() {
|
val isTooNewForSpigot: Boolean get() {
|
||||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
return UpdateUtils.currentMinecraftVersion().major != 1
|
||||||
return versionParts[0] != 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -38,8 +38,8 @@ object PacketManagerSelector {
|
||||||
// Reobfuscated packet manager for spigot or paper as it remap
|
// Reobfuscated packet manager for spigot or paper as it remap
|
||||||
private val reobfPacketManager: PacketManagerBase?
|
private val reobfPacketManager: PacketManagerBase?
|
||||||
get() {
|
get() {
|
||||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
val versionParts = UpdateUtils.currentMinecraftVersion()
|
||||||
if (versionParts[0] != 1) return null
|
if (versionParts.major != 1) return null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val clazz = Class.forName("xyz.alexcrea.cuanvil.dependency.packet.versions." +
|
val clazz = Class.forName("xyz.alexcrea.cuanvil.dependency.packet.versions." +
|
||||||
|
|
@ -47,7 +47,7 @@ object PacketManagerSelector {
|
||||||
|
|
||||||
val manager = clazz.getConstructor().newInstance()
|
val manager = clazz.getConstructor().newInstance()
|
||||||
return manager as PacketManagerBase
|
return manager as PacketManagerBase
|
||||||
} catch (e: ClassNotFoundException) {
|
} catch (_: ClassNotFoundException) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue