Java Code Examples for protocolsupport.api.ProtocolVersion#getProtocolType()

The following examples show how to use protocolsupport.api.ProtocolVersion#getProtocolType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldResourcepacks.java    From ResourcepacksPlugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int getPlayerProtocol(UUID playerId) {
    Player player = getServer().getPlayer(playerId);
    if (player != null) {
        int protocol = serverProtocolVersion;
        if (viaApi != null) {
            protocol = viaApi.getPlayerVersion(playerId);
        }
        if (protocolSupportApi && protocol == serverProtocolVersion) { // if still same format test if player is using previous version
            ProtocolVersion version = ProtocolSupportAPI.getProtocolVersion(player);
            if (version.getProtocolType() == ProtocolType.PC) {
                protocol = version.getId();
            }
        }
        return protocol;
    }
    return -1;
}
 
Example 2
Source File: InitialPacketDecoder.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
protected static ConnectionImpl prepare(Channel channel, ProtocolVersion version) {
	channel.pipeline().remove(ChannelHandlers.INITIAL_DECODER);
	ConnectionImpl connection = ConnectionImpl.getFromChannel(channel);
	if (ServerPlatform.get().getMiscUtils().isDebugging()) {
		ProtocolSupport.logInfo(MessageFormat.format("{0} connected with protocol version {1}", connection.getAddress(), version));
	}
	connection.getNetworkManagerWrapper().setPacketListener(ServerPlatform.get().getMiscUtils().createHandshakeListener(connection.getNetworkManagerWrapper()));
	if (!ProtocolSupportAPI.isProtocolVersionEnabled(version)) {
		if (version.getProtocolType() == ProtocolType.PC) {
			version = version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_6_4) ? ProtocolVersion.MINECRAFT_LEGACY : ProtocolVersion.MINECRAFT_FUTURE;
		} else {
			throw new IllegalArgumentException(MessageFormat.format("Unable to get legacy or future version for disabled protocol version {0}", version));
		}
	}
	connection.setVersion(version);
	return connection;
}
 
Example 3
Source File: AbstractLoginListenerPlay.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void disconnect(final String s) {
	try {
		Bukkit.getLogger().info("Disconnecting " + getConnectionRepr() + ": " + s);
		ProtocolVersion version = connection.getVersion();
		if ((version.getProtocolType() == ProtocolType.PC) && version.isBetween(ProtocolVersion.MINECRAFT_1_7_5, ProtocolVersion.MINECRAFT_1_7_10)) {
			//first send join game that will make client actually switch to game state
			networkManager.sendPacket(ServerPlatform.get().getPacketFactory().createFakeJoinGamePacket());
			//send disconnect with a little delay
			connection.getIOExecutor().schedule(() -> disconnect0(s), 50, TimeUnit.MILLISECONDS);
		} else {
			disconnect0(s);
		}
	} catch (Throwable exception) {
		Bukkit.getLogger().log(Level.SEVERE, "Error whilst disconnecting player", exception);
		networkManager.close("Error whilst disconnecting player, force closing connection");
	}
}
 
Example 4
Source File: PSInitialHandler.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean hasCompression(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8);
}
 
Example 5
Source File: PSInitialHandler.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isFullEncryption(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5);
}
 
Example 6
Source File: StringSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
private static boolean isUsingUTF16(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_6_4);
}
 
Example 7
Source File: StringSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
private static boolean isUsingUTF8(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5);
}
 
Example 8
Source File: MerchantDataSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isUsingAdvancedTrading(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14);
}
 
Example 9
Source File: MerchantDataSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isUsingUsesCount(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8);
}
 
Example 10
Source File: MerchantDataSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isUsingRestockingVillagerField(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14_3);
}
 
Example 11
Source File: MerchantDataSerializer.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isUsingDemand(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14_4);
}
 
Example 12
Source File: AbstractLoginListener.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean isFullEncryption(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5);
}
 
Example 13
Source File: AbstractLoginListener.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static boolean hasCompression(ProtocolVersion version) {
	return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8);
}