Java Code Examples for com.comphenix.protocol.ProtocolManager#sendServerPacket()
The following examples show how to use
com.comphenix.protocol.ProtocolManager#sendServerPacket() .
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: StructureCUI.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
private void sendNbt(Vector pos, NbtCompound compound) { Player player = this.<Player>getPlayer().parent; ProtocolManager manager = ProtocolLibrary.getProtocolManager(); PacketContainer blockNbt = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA); blockNbt.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ())); blockNbt.getIntegers().write(0, 7); blockNbt.getNbtModifier().write(0, compound); try { manager.sendServerPacket(player, blockNbt); } catch (InvocationTargetException e) { e.printStackTrace(); } }
Example 2
Source File: ProtocolLibLoginSource.java From FastLogin with MIT License | 6 votes |
@Override public void kick(String message) throws InvocationTargetException { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); PacketContainer kickPacket = new PacketContainer(DISCONNECT); kickPacket.getChatComponents().write(0, WrappedChatComponent.fromText(message)); try { //send kick packet at login state //the normal event.getPlayer.kickPlayer(String) method does only work at play state protocolManager.sendServerPacket(player, kickPacket); } finally { //tell the server that we want to close the connection player.kickPlayer("Disconnect"); } }
Example 3
Source File: InventoryPacketAdapter.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
/** * Sends a blanked out packet to the given player in order to hide the inventory. * * @param player the player to send the blank inventory packet to */ public void sendBlankInventoryPacket(Player player) { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS); inventoryPacket.getIntegers().write(0, PLAYER_INVENTORY); int inventorySize = CRAFTING_SIZE + ARMOR_SIZE + MAIN_SIZE + HOTBAR_SIZE; ItemStack[] blankInventory = new ItemStack[inventorySize]; Arrays.fill(blankInventory, new ItemStack(Material.AIR)); //old minecraft versions StructureModifier<ItemStack[]> itemArrayModifier = inventoryPacket.getItemArrayModifier(); if (itemArrayModifier.size() > 0) { itemArrayModifier.write(0, blankInventory); } else { //minecraft versions above 1.11 StructureModifier<List<ItemStack>> itemListModifier = inventoryPacket.getItemListModifier(); itemListModifier.write(0, Arrays.asList(blankInventory)); } try { protocolManager.sendServerPacket(player, inventoryPacket, false); } catch (InvocationTargetException invocationExc) { logger.logException("Error during sending blank inventory", invocationExc); } }
Example 4
Source File: AbstractPacket.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public void sendPacket(Player player) { try { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); manager.sendServerPacket(player, getHandle()); } catch(InvocationTargetException ex) { throw new RuntimeException("Cannot send packet", ex); } }
Example 5
Source File: StructureCUI.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private void sendOp() { Player player = this.<Player>getPlayer().parent; ProtocolManager manager = ProtocolLibrary.getProtocolManager(); PacketConstructor statusCtr = manager.createPacketConstructor(PacketType.Play.Server.ENTITY_STATUS, player, (byte) 28); PacketContainer status = statusCtr.createPacket(player, (byte) 28); try { manager.sendServerPacket(player, status); } catch (InvocationTargetException e) { e.printStackTrace(); } }
Example 6
Source File: SkinApplier.java From ChangeSkin with MIT License | 5 votes |
private void sendPackets(PacketContainer... packets) { try { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); for (PacketContainer packet : packets) { protocolManager.sendServerPacket(receiver, packet); } } catch (InvocationTargetException ex) { plugin.getLog().error("Exception sending instant skin change packet for: {}", receiver, ex); } }