Port version support

This commit is contained in:
Aust1n46 2022-08-23 22:02:12 -05:00
parent 6b3112f6a4
commit 347dd2d396

View File

@ -1,58 +1,88 @@
package venture.Aust1n46.chat.xcut; package venture.Aust1n46.chat.xcut;
import com.google.inject.Inject; import com.comphenix.protocol.utility.MinecraftVersion;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.initiators.application.VentureChat; @Singleton
public final class VersionService {
public static final MinecraftVersion SERVER_VERSION = MinecraftVersion.getCurrentVersion();
public class VersionService { private VersionService() {
@Inject }
private VentureChat plugin;
public boolean is1_7() { public boolean is1_7() {
return plugin.getServer().getVersion().contains("1.7"); return SERVER_VERSION.getMinor() == 7 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_8() { public boolean is1_8() {
return plugin.getServer().getVersion().contains("1.8"); return SERVER_VERSION.getMinor() == 8 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_9() { public boolean is1_9() {
return plugin.getServer().getVersion().contains("1.9"); return SERVER_VERSION.getMinor() == 9 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_10() { public boolean is1_10() {
return plugin.getServer().getVersion().contains("1.10"); return SERVER_VERSION.getMinor() == 10 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_11() { public boolean is1_11() {
return plugin.getServer().getVersion().contains("1.11"); return SERVER_VERSION.getMinor() == 11 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_12() { public boolean is1_12() {
return plugin.getServer().getVersion().contains("1.12"); return SERVER_VERSION.getMinor() == 12 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_13() { public boolean is1_13() {
return plugin.getServer().getVersion().contains("1.13"); return SERVER_VERSION.getMinor() == 13 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_14() { public boolean is1_14() {
return plugin.getServer().getVersion().contains("1.14"); return SERVER_VERSION.getBuild() != 4 && SERVER_VERSION.getMinor() == 14 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_14_4() { public boolean is1_14_4() {
return plugin.getServer().getVersion().contains("1.14.4"); return SERVER_VERSION.getBuild() == 4 && SERVER_VERSION.getMinor() == 14 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_15() { public boolean is1_15() {
return plugin.getServer().getVersion().contains("1.15"); return SERVER_VERSION.getMinor() == 15 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_16() { public boolean is1_16() {
return plugin.getServer().getVersion().contains("1.16"); return SERVER_VERSION.getMinor() == 16 && SERVER_VERSION.getMajor() == 1;
} }
public boolean is1_17() { public boolean is1_17() {
return plugin.getServer().getVersion().contains("1.17"); return SERVER_VERSION.getMinor() == 17 && SERVER_VERSION.getMajor() == 1;
}
public boolean is1_18() {
return SERVER_VERSION.getMinor() == 18 && SERVER_VERSION.getMajor() == 1;
}
public boolean is1_19() {
return SERVER_VERSION.getBuild() == 0 && SERVER_VERSION.getMinor() == 19 && SERVER_VERSION.getMajor() == 1;
}
public boolean isUnder_1_19() {
if (SERVER_VERSION.getMajor() < 1) {
return true;
}
return SERVER_VERSION.getMajor() == 1 && SERVER_VERSION.getMinor() < 19;
}
public boolean isAbove_1_19() {
if (SERVER_VERSION.getMajor() < 1) {
return false;
}
if (SERVER_VERSION.getMajor() > 1) {
return true;
}
if (SERVER_VERSION.getMinor() > 19) {
return true;
}
return SERVER_VERSION.getMinor() == 19 && SERVER_VERSION.getBuild() > 0;
} }
} }