Java Code Examples for protocolsupport.api.ProtocolType#PC
The following examples show how to use
protocolsupport.api.ProtocolType#PC .
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: FeatureEmulation.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (((event.getCause() == DamageCause.FIRE_TICK) || (event.getCause() == DamageCause.FIRE) || (event.getCause() == DamageCause.DROWNING))) { for (Player player : ServerPlatform.get().getMiscUtils().getNearbyPlayers(event.getEntity().getLocation(), 48, 128, 48)) { if (player != null) { Connection connection = ProtocolSupportAPI.getConnection(player); if ( (connection != null) && (connection.getVersion().getProtocolType() == ProtocolType.PC) && connection.getVersion().isBefore(ProtocolVersion.MINECRAFT_1_12) ) { connection.sendPacket(ServerPlatform.get().getPacketFactory().createEntityStatusPacket(event.getEntity(), 2)); } } } } }
Example 2
Source File: FeatureEmulation.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); Connection connection = ProtocolSupportAPI.getConnection(player); if ( (connection != null) && (connection.getVersion().getProtocolType() == ProtocolType.PC) && connection.getVersion().isBefore(ProtocolVersion.MINECRAFT_1_9) ) { BlockDataEntry blockdataentry = MinecraftBlockData.get(MaterialAPI.getBlockDataNetworkId(event.getBlock().getBlockData())); player.playSound( event.getBlock().getLocation(), blockdataentry.getBreakSound(), SoundCategory.BLOCKS, (blockdataentry.getVolume() + 1.0F) / 2.0F, blockdataentry.getPitch() * 0.8F ); } }
Example 3
Source File: InitialPacketDecoder.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
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 4
Source File: WorldResourcepacks.java From ResourcepacksPlugins with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: AbstractLoginListenerPlay.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@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 6
Source File: FeatureEmulation.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void onShift(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); Connection connection = ProtocolSupportAPI.getConnection(player); if ( player.isInsideVehicle() && (connection != null) && (connection.getVersion().getProtocolType() == ProtocolType.PC) && connection.getVersion().isBeforeOrEq(ProtocolVersion.MINECRAFT_1_5_2) ) { player.leaveVehicle(); } }
Example 7
Source File: MiddleCollectEffect.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public void handleReadData() { //TODO: send needed collect packets from middle packet itself after implementing serverside entity position cache if ( (collectorId == cache.getEntityCache().getSelfId()) && (version.getProtocolType() == ProtocolType.PC) && version.isBefore(ProtocolVersion.MINECRAFT_1_9) ) { Player player = connection.getPlayer(); NetworkEntity entity = cache.getEntityCache().getEntity(entityId); if ((entity != null) && (player != null)) { switch (entity.getType()) { case ITEM: { player.playSound( player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F ); break; } case EXP_ORB: { player.playSound( player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F ); break; } default: { break; } } } } }
Example 8
Source File: MerchantDataSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isUsingRestockingVillagerField(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14_3); }
Example 9
Source File: AbstractLoginListener.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean hasCompression(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8); }
Example 10
Source File: AbstractLoginListener.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isFullEncryption(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5); }
Example 11
Source File: MerchantDataSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isUsingDemand(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14_4); }
Example 12
Source File: MerchantDataSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isUsingUsesCount(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8); }
Example 13
Source File: MerchantDataSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isUsingAdvancedTrading(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_14); }
Example 14
Source File: StringSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
private static boolean isUsingUTF8(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5); }
Example 15
Source File: StringSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
private static boolean isUsingUTF16(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_6_4); }
Example 16
Source File: PSInitialHandler.java From ProtocolSupportBungee with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean isFullEncryption(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_7_5); }
Example 17
Source File: PSInitialHandler.java From ProtocolSupportBungee with GNU Affero General Public License v3.0 | 4 votes |
protected static boolean hasCompression(ProtocolVersion version) { return (version.getProtocolType() == ProtocolType.PC) && version.isAfterOrEq(ProtocolVersion.MINECRAFT_1_8); }