Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Merge pull request #239 from Matsv/master
Add api method to get player's protocol id
Dieser Commit ist enthalten in:
Commit
d40c5851e9
@ -5,6 +5,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -195,6 +196,13 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
return isPorted(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerVersion(@NonNull Player player) {
|
||||
if (!isPorted(player))
|
||||
return 47;
|
||||
return portedPlayers.get(player.getUniqueId()).getProtocol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPorted(UUID playerUUID) {
|
||||
return portedPlayers.containsKey(playerUUID);
|
||||
|
@ -10,13 +10,20 @@ import java.util.UUID;
|
||||
|
||||
public interface ViaVersionAPI {
|
||||
/**
|
||||
* Is player using 1.9?
|
||||
* Is the player connection modified by ViaVersion?
|
||||
*
|
||||
* @param player
|
||||
* @return True if the client is on 1.9
|
||||
* @param player Bukkit player object
|
||||
* @return True if the client is modified (At the moment it also means version 1.9 and higher)
|
||||
*/
|
||||
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?
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren