Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dashnetwork.protocolsupportpotions.utils;
- import org.bukkit.entity.Player;
- import dashnetwork.protocolsupportpotions.main.Main;
- import protocolsupport.api.ProtocolSupportAPI;
- import us.myles.ViaVersion.api.Via;
- public class ProtocolUtils {
- private static Main plugin = Main.getInstance();
- public static boolean getAPI() {
- if (plugin.getServer().getPluginManager().getPlugin("ProtocolSupport") != null) {
- return true;
- }
- else if (plugin.getServer().getPluginManager().getPlugin("ViaVersion") != null) {
- return false;
- }
- else {
- plugin.getLogger().severe("ProtocolSupport or ViaVersion not detected!");
- plugin.getServer().getPluginManager().disablePlugin(plugin);
- return false;
- }
- }
- private static int getProtocolSupport(Player player) {
- if (ProtocolSupportAPI.getProtocolVersion(player).getName() == null) {
- return -1;
- }
- else {
- return ProtocolSupportAPI.getProtocolVersion(player).getId();
- }
- }
- private static int getViaVersion(Player player) {
- return Via.getAPI().getPlayerVersion(player.getUniqueId());
- }
- public static boolean isOlder(Player player, boolean value) {
- if (getAPI()) {
- return getProtocolSupport(player) <= (value ? 210 : 47);
- }
- else {
- return getViaVersion(player) <= (value ? 210 : 47);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment