From e528f51388a27440d2319b35302fb6391247aa2d Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Mon, 4 Oct 2021 20:32:32 +0200 Subject: [PATCH] Replace dependency `viaversion-bukkit` with latest `viaversion-api` --- Compatibility/pom.xml | 6 +++--- .../java/com/songoda/core/compatibility/ClientVersion.java | 7 ++++--- .../java/com/songoda/core/compatibility/ServerVersion.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Compatibility/pom.xml b/Compatibility/pom.xml index 055ab1a5..e9ab33c1 100644 --- a/Compatibility/pom.xml +++ b/Compatibility/pom.xml @@ -22,9 +22,9 @@ - us.myles.viaversion-bukkit - ViaVersion - 2.1.3 + com.viaversion + viaversion-api + 4.0.1 provided diff --git a/Compatibility/src/main/java/com/songoda/core/compatibility/ClientVersion.java b/Compatibility/src/main/java/com/songoda/core/compatibility/ClientVersion.java index 2964b473..92b0daed 100644 --- a/Compatibility/src/main/java/com/songoda/core/compatibility/ClientVersion.java +++ b/Compatibility/src/main/java/com/songoda/core/compatibility/ClientVersion.java @@ -1,5 +1,6 @@ package com.songoda.core.compatibility; +import com.viaversion.viaversion.api.Via; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -12,8 +13,7 @@ import java.util.UUID; * NOTE: this is automatically initialized through SongodaCore */ public class ClientVersion { - - static HashMap players = new HashMap(); + static HashMap players = new HashMap<>(); /** * Check to see what client version this player is connected to the server @@ -28,6 +28,7 @@ public class ClientVersion { if (player == null || !players.containsKey(player.getUniqueId())) { return ServerVersion.getServerVersion(); } + return players.get(player.getUniqueId()); } @@ -51,7 +52,7 @@ public class ClientVersion { public static void onLoginVia(Player p, JavaPlugin plugin) { Bukkit.getScheduler().runTaskLater(plugin, () -> { if (p.isOnline()) { - final int version = us.myles.ViaVersion.api.Via.getAPI().getPlayerVersion(p.getUniqueId()); + final int version = Via.getAPI().getPlayerVersion(p.getUniqueId()); players.put(p.getUniqueId(), protocolToVersion(version)); } }, 20); diff --git a/Compatibility/src/main/java/com/songoda/core/compatibility/ServerVersion.java b/Compatibility/src/main/java/com/songoda/core/compatibility/ServerVersion.java index 486df2cf..39ed48f8 100644 --- a/Compatibility/src/main/java/com/songoda/core/compatibility/ServerVersion.java +++ b/Compatibility/src/main/java/com/songoda/core/compatibility/ServerVersion.java @@ -4,7 +4,6 @@ import org.apache.commons.lang.ArrayUtils; import org.bukkit.Bukkit; public enum ServerVersion { - UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21; private final static String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName(); @@ -18,6 +17,7 @@ public enum ServerVersion { return version; } } + return UNKNOWN; }