Replace dependency viaversion-bukkit with latest viaversion-api

This commit is contained in:
Christian Koop 2021-10-04 20:32:32 +02:00
parent fb8d38f54b
commit e528f51388
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 8 additions and 7 deletions

View File

@ -22,9 +22,9 @@
</dependency>
<dependency>
<groupId>us.myles.viaversion-bukkit</groupId>
<artifactId>ViaVersion</artifactId>
<version>2.1.3</version>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>

View File

@ -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<UUID, ServerVersion> players = new HashMap();
static HashMap<UUID, ServerVersion> 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);

View File

@ -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;
}