diff --git a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java index e16e25321..19a3939bc 100644 --- a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java +++ b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java @@ -9,7 +9,6 @@ import lombok.Getter; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import us.myles.ViaVersion.api.Pair; @@ -29,6 +28,7 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.update.UpdateListener; import us.myles.ViaVersion.update.UpdateUtil; import us.myles.ViaVersion.util.ListWrapper; +import us.myles.ViaVersion.util.ProtocolSupportUtil; import us.myles.ViaVersion.util.ReflectionUtil; import java.lang.reflect.Field; @@ -338,17 +338,25 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI { @Override public int getPlayerVersion(@NonNull Player player) { if (!isPorted(player)) - return ProtocolRegistry.SERVER_PROTOCOL; + return getExternalVersion(player); return portedPlayers.get(player.getUniqueId()).get(ProtocolInfo.class).getProtocolVersion(); } @Override public int getPlayerVersion(@NonNull UUID uuid) { if (!isPorted(uuid)) - return ProtocolRegistry.SERVER_PROTOCOL; + return getExternalVersion(Bukkit.getPlayer(uuid)); return portedPlayers.get(uuid).get(ProtocolInfo.class).getProtocolVersion(); } + private int getExternalVersion(Player player) { + if (!isProtocolSupport()) { + return ProtocolRegistry.SERVER_PROTOCOL; + } else { + return ProtocolSupportUtil.getProtocolVersion(player); + } + } + @Override public boolean isPorted(UUID playerUUID) { return portedPlayers.containsKey(playerUUID); diff --git a/src/main/java/us/myles/ViaVersion/api/ViaVersionAPI.java b/src/main/java/us/myles/ViaVersion/api/ViaVersionAPI.java index 5e2dca295..57743784d 100644 --- a/src/main/java/us/myles/ViaVersion/api/ViaVersionAPI.java +++ b/src/main/java/us/myles/ViaVersion/api/ViaVersionAPI.java @@ -21,6 +21,7 @@ public interface ViaVersionAPI { /** * Get protocol number from a player + * Will also retrieve version from ProtocolSupport if it's being used. * * @param player Bukkit player object * @return Protocol ID, For example (47=1.8-1.8.8, 107=1.9, 108=1.9.1) @@ -120,8 +121,9 @@ public interface ViaVersionAPI { /** * Gets if the server uses spigot - * + *
* Note: Will only work after ViaVersion load
+ *
* @return True if spigot
*/
boolean isSpigot();
diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java
index 2fb6c0468..bc2ce650b 100644
--- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java
+++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java
@@ -9,6 +9,13 @@ import java.util.*;
public class ProtocolVersion {
private static final Map