mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 10:35:12 +01:00
Add api method to get player's protocol id,
This commit is contained in:
parent
0d3ba67233
commit
d0e573613b
@ -5,6 +5,7 @@ import io.netty.channel.ChannelFuture;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -195,6 +196,13 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
return isPorted(player.getUniqueId());
|
return isPorted(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPlayerVersion(@NonNull Player player) {
|
||||||
|
if (!isPorted(player))
|
||||||
|
return 47;
|
||||||
|
return portedPlayers.get(player.getUniqueId()).getProtocol();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPorted(UUID playerUUID) {
|
public boolean isPorted(UUID playerUUID) {
|
||||||
return portedPlayers.containsKey(playerUUID);
|
return portedPlayers.containsKey(playerUUID);
|
||||||
|
@ -10,13 +10,20 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface ViaVersionAPI {
|
public interface ViaVersionAPI {
|
||||||
/**
|
/**
|
||||||
* Is player using 1.9?
|
* Is the player connection modified by ViaVersion?
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player Bukkit player object
|
||||||
* @return True if the client is on 1.9
|
* @return True if the client is modified (At the moment it also means version 1.9 and higher)
|
||||||
*/
|
*/
|
||||||
boolean isPorted(Player player);
|
boolean isPorted(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get protocol number from a player
|
||||||
|
* @param player Bukkit player object
|
||||||
|
* @return Protocol ID, For example (47=1.8-1.8.8, 107=1.9, 108=1.9.1)
|
||||||
|
*/
|
||||||
|
int getPlayerVersion(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is player using 1.9?
|
* Is player using 1.9?
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user