Java Code Examples for com.comphenix.protocol.ProtocolLibrary#getProtocolManager()
The following examples show how to use
com.comphenix.protocol.ProtocolLibrary#getProtocolManager() .
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: 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 2
Source File: ChatItem.java From ChatItem with GNU General Public License v3.0 | 6 votes |
public static void reload(CommandSender sender) { ChatItem obj = getInstance(); obj.pm = ProtocolLibrary.getProtocolManager(); obj.saveDefaultConfig(); obj.reloadConfig(); obj.storage = new Storage(obj.getConfig()); obj.packetListener.setStorage(obj.storage); obj.packetValidator.setStorage(obj.storage); obj.chatEventListener.setStorage(obj.storage); obj.filter.setStorage(obj.storage); APIImplementation api = (APIImplementation) Bukkit.getServicesManager().getRegistration(ChatItemAPI.class).getProvider(); api.setStorage(obj.storage); api.updateLogger(); if (!obj.storage.RELOAD_MESSAGE.isEmpty()) sender.sendMessage(obj.storage.RELOAD_MESSAGE); }
Example 3
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 4
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 5
Source File: BukkitQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void sendChunkUpdatePLIB(FaweChunk chunk, FawePlayer... players) { PlayerChunkMap playerManager = ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap(); ProtocolManager manager = ProtocolLibrary.getProtocolManager(); WirePacket packet = null; try { for (int i = 0; i < players.length; i++) { CraftPlayer bukkitPlayer = ((CraftPlayer) ((BukkitPlayer) players[i]).parent); EntityPlayer player = bukkitPlayer.getHandle(); if (playerManager.a(player, chunk.getX(), chunk.getZ())) { if (packet == null) { byte[] data; byte[] buffer = new byte[8192]; if (chunk instanceof LazyFaweChunk) { chunk = (FaweChunk) chunk.getChunk(); } if (chunk instanceof MCAChunk) { data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer); } else { data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer); } packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data); } manager.sendWirePacket(bukkitPlayer, packet); } } } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
Example 6
Source File: WrapperPlayServerMount.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
public List<Entity> getPassengers(World world) { int[] ids = getPassengerIds(); List<Entity> passengers = new ArrayList<>(); ProtocolManager manager = ProtocolLibrary.getProtocolManager(); for (int id : ids) { Entity entity = manager.getEntityFromID(world, id); if (entity != null) { passengers.add(entity); } } return passengers; }
Example 7
Source File: EntityHider.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
/** * Construct a new entity hider. * * @param plugin - the plugin that controls this entity hider. * @param policy - the default visibility policy. */ public EntityHider(Plugin plugin, Policy policy) { Preconditions.checkNotNull(plugin, "plugin cannot be NULL."); // Save policy this.policy = policy; this.manager = ProtocolLibrary.getProtocolManager(); // Register events and packet listener plugin.getServer().getPluginManager().registerEvents( bukkitListener = constructBukkit(), plugin); manager.addPacketListener( protocolListener = constructProtocol(plugin)); }
Example 8
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); } }
Example 9
Source File: BukkitQueue_0.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public void sendChunkUpdatePLIB(FaweChunk chunk, FawePlayer... players) { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); WirePacket packet = null; int viewDistance = Bukkit.getViewDistance(); try { for (int i = 0; i < players.length; i++) { int cx = chunk.getX(); int cz = chunk.getZ(); Player player = ((BukkitPlayer) players[i]).parent; Location loc = player.getLocation(); if (Math.abs((loc.getBlockX() >> 4) - cx) <= viewDistance && Math.abs((loc.getBlockZ() >> 4) - cz) <= viewDistance) { if (packet == null) { byte[] data; byte[] buffer = new byte[8192]; if (chunk instanceof LazyFaweChunk) { chunk = (FaweChunk) chunk.getChunk(); } if (chunk instanceof MCAChunk) { data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer); } else { data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer); } packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data); } manager.sendWirePacket(player, packet); } } } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
Example 10
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 11
Source File: AbstractPacket.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public void receivePacket(Player player) { try { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); manager.recieveClientPacket(player, getHandle()); } catch(InvocationTargetException | IllegalAccessException ex) { throw new RuntimeException("Cannot receive packet", ex); } }
Example 12
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 13
Source File: ForceField.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public void unregisterProtocol() { PluginManager pluginManager = Bukkit.getPluginManager(); if(!pluginManager.isPluginEnabled("ProtocolLib")) return; ProtocolManager manager = ProtocolLibrary.getProtocolManager(); manager.removePacketListeners(this.plugin.getPlugin()); }
Example 14
Source File: PlayerInformationModifier.java From AACAdditionPro with GNU General Public License v3.0 | 5 votes |
/** * Allow the observer to see an entity that was previously hidden. * * @param observer - the observer. * @param entity - the entity to show. */ public final void unModifyInformation(final Player observer, final Entity entity) { validate(observer, entity); final boolean hiddenBefore = !setModifyInformation(observer, entity.getEntityId(), true); // Resend packets if (ProtocolLibrary.getProtocolManager() != null && hiddenBefore) { ProtocolLibrary.getProtocolManager().updateEntity(entity, Collections.singletonList(observer)); } }
Example 15
Source File: ProtocolLibHook.java From StackMob-3 with GNU General Public License v3.0 | 5 votes |
@Override public void enable(){ if(getStackMob().getCustomConfig().getBoolean("tag.show-player-nearby.enabled")){ protocolManager = ProtocolLibrary.getProtocolManager(); getHookManager().registerHook(PluginCompat.PROCOTOLLIB, this); } }
Example 16
Source File: AbstractPacket.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
public void broadcastPacket() { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); manager.broadcastServerPacket(getHandle()); }
Example 17
Source File: ForceField.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
public void registerProtocol() { ProtocolManager manager = ProtocolLibrary.getProtocolManager(); PacketAdapter adapter = new ForceFieldAdapter(this); manager.addPacketListener(adapter); }
Example 18
Source File: ProtocolLibHook.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
public ProtocolManager getProtocolManager() { return ProtocolLibrary.getProtocolManager(); }
Example 19
Source File: Protocol.java From helper with MIT License | 2 votes |
/** * Gets the protocol manager. * * @return the protocol manager. */ @Nonnull public static ProtocolManager manager() { return ProtocolLibrary.getProtocolManager(); }