Java Code Examples for com.comphenix.protocol.PacketType

The following examples show how to use com.comphenix.protocol.PacketType. These examples are extracted from open source projects. 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 Project: helper   Source File: PacketScoreboardObjective.java    License: MIT License 6 votes vote down vote up
private PacketContainer newObjectivePacket(UpdateType mode) {
    // http://wiki.vg/Protocol#Scoreboard_Objective
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);

    // set name - limited to String(16)
    packet.getStrings().write(0, getId());

    // set mode - 0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.
    packet.getIntegers().write(0, mode.getCode());

    if (USING_CHAT_COMPONENTS) {
        // set display name - Component
        packet.getChatComponents().write(0, PacketScoreboard.toComponent(getDisplayName()));
    } else {
        // set display name - limited to String(16) - Only if mode is 0 or 2. The text to be displayed for the score
        packet.getStrings().write(1, getDisplayName());
    }

    // set type - either "integer" or "hearts"
    packet.getEnumModifier(HealthDisplay.class, 2).write(0, HealthDisplay.INTEGER);

    return packet;
}
 
Example 2
Source Project: helper   Source File: PacketScoreboardTeam.java    License: MIT License 6 votes vote down vote up
private PacketContainer newTeamMemberUpdatePacket(String player, MemberAction action) {
    // http://wiki.vg/Protocol#Teams
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);

    // set team name - 	String (16)
    packet.getStrings().write(0, getId());

    // set mode
    switch (action) {
        case ADD:
            packet.getIntegers().write(GTEQ_1_13 ? 0 : 1, UpdateType.ADD_PLAYERS.getCode());
            break;
        case REMOVE:
            packet.getIntegers().write(GTEQ_1_13 ? 0 : 1, UpdateType.REMOVE_PLAYERS.getCode());
            break;
        default:
            throw new RuntimeException();
    }

    // set players - Array of String (40)
    packet.getSpecificModifier(Collection.class).write(0, Collections.singletonList(player));
    
    return packet;
}
 
Example 3
Source Project: NameTagChanger   Source File: ProtocolLibPacketHandler.java    License: MIT License 6 votes vote down vote up
@Override
public void sendNamedEntitySpawnPacket(Player playerToSpawn, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
    packet.getIntegers().write(0, playerToSpawn.getEntityId());
    packet.getUUIDs().write(0, playerToSpawn.getUniqueId());
    if (ReflectUtil.isVersionHigherThan(1, 8, 8)) {
        packet.getDoubles().write(0, playerToSpawn.getLocation().getX());
        packet.getDoubles().write(1, playerToSpawn.getLocation().getY());
        packet.getDoubles().write(2, playerToSpawn.getLocation().getZ());
    } else {
        packet.getIntegers().write(0, (int) Math.floor(playerToSpawn.getLocation().getX() * 32D));
        packet.getIntegers().write(1, (int) Math.floor(playerToSpawn.getLocation().getY() * 32D));
        packet.getIntegers().write(2, (int) Math.floor(playerToSpawn.getLocation().getZ() * 32D));
    }
    packet.getBytes().write(0, (byte) (playerToSpawn.getLocation().getYaw() * 256F / 360F));
    packet.getBytes().write(1, (byte) (playerToSpawn.getLocation().getPitch() * 256F / 360F));
    packet.getDataWatcherModifier().write(0, WrappedDataWatcher.getEntityWatcher(playerToSpawn));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        logMessage(Level.SEVERE, "Failed to send named entity spawn packet!", e);
    }
}
 
Example 4
/**
 * 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 5
/**
 * Construct a chunk packet processor from a givne MAP_CHUNK packet.
 * @param packet - the map chunk packet.
 * @return The chunk packet processor.
 */
public static ChunkPacketProcessor fromMapPacket(PacketContainer packet, World world) {
	if (!packet.getType().equals(PacketType.Play.Server.MAP_CHUNK))
		throw new IllegalArgumentException(packet + " must be a MAP_CHUNK packet.");
	
	StructureModifier<Integer> ints = packet.getIntegers();
	StructureModifier<byte[]> byteArray = packet.getByteArrays();
    
    // Create an info objects
	ChunkPacketProcessor processor = new ChunkPacketProcessor();
	processor.world = world;
    processor.chunkX = ints.read(0); 	 // packet.a;
    processor.chunkZ = ints.read(1); 	 // packet.b;
    processor.chunkMask = ints.read(2);  // packet.c;
    processor.extraMask = ints.read(3);  // packet.d;
    processor.data = byteArray.read(1);  // packet.inflatedBuffer;
    processor.startIndex = 0;

    if (packet.getBooleans().size() > 0) {
    	processor.hasContinous = packet.getBooleans().read(0);
    }
    return processor;
}
 
Example 6
Source Project: StackMob-3   Source File: ProtocolLibHook.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void sendPacket(Player player, Entity entity, boolean visible){
    PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
    // Cloning the packet and getting the entity involved.
    WrappedDataWatcher watcher = new WrappedDataWatcher(entity);
    WrappedDataWatcher.Serializer booleanSerializer = WrappedDataWatcher.Registry.get(Boolean.class);
    // Set if the tag is visible or not.
    watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, booleanSerializer), visible);
    // Writing the stuff to the packet.
    packet.getEntityModifier(entity.getWorld()).write(0, entity);
    packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());

    // Send the new packet.
    try{
        protocolManager.sendServerPacket(player, packet);
    }catch (InvocationTargetException e){
        e.printStackTrace();
    }
}
 
Example 7
Source Project: ScoreboardStats   Source File: PacketListener.java    License: MIT License 6 votes vote down vote up
private void ensureMainThread(UUID uuid, PacketContainer packet) {
    Player player = Bukkit.getPlayer(uuid);
    if (player == null) {
        return;
    }

    PacketType packetType = packet.getType();
    if (packetType.equals(SCOREBOARD_SCORE)) {
        handleScorePacket(player, packet);
    } else if (packetType.equals(SCOREBOARD_OBJECTIVE)) {
        handleObjectivePacket(player, packet);
    } else if (packetType.equals(SCOREBOARD_DISPLAY_OBJECTIVE)) {
        handleDisplayPacket(player, packet);
    } else if (packetType.equals(SCOREBOARD_TEAM)) {
        handleTeamPacket(player, packet);
    }
}
 
Example 8
@Override
protected int process(User user, PacketEvent packetEvent)
{
    if (packetEvent.getPacketType() == PacketType.Play.Client.ARM_ANIMATION) {
        user.getDataMap().setValue(DataKey.PACKET_ANALYSIS_ANIMATION_EXPECTED, false);
    } else {
        if (user.getDataMap().getBoolean(DataKey.PACKET_ANALYSIS_ANIMATION_EXPECTED)) {
            user.getDataMap().setValue(DataKey.PACKET_ANALYSIS_ANIMATION_EXPECTED, false);
            message = "PacketAnalysisData-Verbose | Player: " + user.getPlayer().getName() + " did not send animation packet after an attack.";
            return 10;
        }
    }

    if (packetEvent.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
        // Make sure an arm animation packet is sent directly after an attack as it is the next packet in the client
        // code.
        final WrapperPlayClientUseEntity useEntityWrapper = new WrapperPlayClientUseEntity(packetEvent.getPacket());
        if (useEntityWrapper.getType() == EnumWrappers.EntityUseAction.ATTACK) {
            user.getDataMap().setValue(DataKey.PACKET_ANALYSIS_ANIMATION_EXPECTED, true);
        }
        return 0;
    }
    return 0;
}
 
Example 9
@Override
public void onPacketSending(PacketEvent event)
{
    if (event.isPlayerTemporary()) {
        return;
    }

    final User user = UserManager.getUser(event.getPlayer().getUniqueId());

    // Not bypassed
    if (User.isUserInvalid(user, this.getModuleType())) {
        return;
    }

    if (event.getPacketType() == PacketType.Play.Server.POSITION) {
        final WrapperPlayServerPosition newPositionWrapper = new WrapperPlayServerPosition(event.getPacket());

        // Ignore relative teleports.
        if (!newPositionWrapper.getFlags().isEmpty()) {
            return;
        }

        user.getDataMap().setValue(DataKey.PACKET_ANALYSIS_LAST_POSITION_FORCE_LOCATION, newPositionWrapper.getLocation(user.getPlayer().getWorld()));
        user.getTimestampMap().updateTimeStamp(TimestampKey.PACKET_ANALYSIS_LAST_POSITION_FORCE);
    }
}
 
Example 10
private void sendTitle(SpleefPlayer player, String title, String subtitle) throws InvocationTargetException {
	Player bukkitPlayer = player.getBukkitPlayer();
	
	PacketContainer timesPacket = manager.createPacket(PacketType.Play.Server.TITLE);
	timesPacket.getTitleActions().write(0, TitleAction.TIMES);
	timesPacket.getIntegers().write(0, FADE_IN);
	timesPacket.getIntegers().write(1, SHOW_LENGTH);
	timesPacket.getIntegers().write(2, FADE_OUT);
	manager.sendServerPacket(bukkitPlayer, timesPacket);
	
	if (title != null) {
		PacketContainer titlePacket = manager.createPacket(PacketType.Play.Server.TITLE);
		titlePacket.getTitleActions().write(0, TitleAction.TITLE);
		titlePacket.getChatComponents().write(0, getChatComponent(title));
		manager.sendServerPacket(bukkitPlayer, titlePacket);
	}
	
	if (subtitle != null) {
		PacketContainer subtitlePacket = manager.createPacket(PacketType.Play.Server.TITLE);
		subtitlePacket.getTitleActions().write(0, TitleAction.SUBTITLE);
		subtitlePacket.getChatComponents().write(0, getChatComponent(subtitle));
		manager.sendServerPacket(bukkitPlayer, subtitlePacket);
	}
}
 
Example 11
Source Project: AACAdditionPro   Source File: PlayerHider.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void modifyInformation(final Player observer, final Entity entity)
{
    validate(observer, entity);

    if (setModifyInformation(observer, entity.getEntityId(), false)) {
        //Create new packet which destroys the entity
        final PacketContainer destroyEntity = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
        destroyEntity.getIntegerArrays().write(0, new int[]{entity.getEntityId()});

        // Make the entity disappear
        try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(observer, destroyEntity);
        } catch (final InvocationTargetException e) {
            throw new RuntimeException("Cannot send server packet.", e);
        }
    }
}
 
Example 12
Source Project: HeavySpleef   Source File: FlagShowBarriers.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void spawnBarrier(Vector vector) {
	PacketContainer packet = manager.createPacket(PacketType.Play.Server.WORLD_PARTICLES);
	packet.getParticles().write(0, Particle.BARRIER); //Particle itself
	packet.getFloat().write(0, (float)vector.getX()); //x
	packet.getFloat().write(1, (float)vector.getY()); //y
	packet.getFloat().write(2, (float)vector.getZ()); //z
	packet.getIntegers().write(0, 1); //Number of particles
	
	try {
		for (SpleefPlayer player : game.getPlayers()) {
			Player bukkitPlayer = player.getBukkitPlayer();
			manager.sendServerPacket(bukkitPlayer, packet);
		}
	} catch (InvocationTargetException e) {
		getHeavySpleef().getLogger().log(Level.SEVERE, "Exception occured while sending barrier particle packet", e);
	}
}
 
Example 13
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 14
Source Project: FastLogin   Source File: ProtocolLibListener.java    License: MIT License 6 votes vote down vote up
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
    if (packetEvent.isCancelled()
            || plugin.getCore().getAuthPluginHook()== null
            || !plugin.isServerFullyStarted()) {
        return;
    }

    Player sender = packetEvent.getPlayer();
    PacketType packetType = packetEvent.getPacketType();
    if (packetType == START) {
        if (!rateLimiter.tryAcquire()) {
            plugin.getLog().warn("Rate Limit hit - Ignoring player {}", sender);
            return;
        }

        onLogin(packetEvent, sender);
    } else {
        onEncryptionBegin(packetEvent, sender);
    }
}
 
Example 15
Source Project: helper   Source File: PacketIndividualHologramFactory.java    License: MIT License 5 votes vote down vote up
@Override
public void removeViewer(@Nonnull Player player) {
    if (!this.viewers.remove(player)) {
        return;
    }

    // handle removing the existing entity?
    PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);

    // set ids
    int[] ids = this.spawnedEntities.stream().mapToInt(HologramEntity::getId).toArray();
    destroyPacket.getIntegerArrays().write(0, ids);

    Protocol.sendPacket(player, destroyPacket);
}
 
Example 16
@Override // Handshake
public void onPacketReceiving(PacketEvent event) {
    if (bukkit.getCore() == null) return; // Too early, we haven't finished initializing yet

    PacketContainer packet = event.getPacket();
    if (packet.getProtocols().read(0) != PacketType.Protocol.STATUS) return;

    StatusRequest request = bukkit.getRequest(event.getPlayer().getAddress());
    request.setProtocolVersion(packet.getIntegers().read(0));

    String host = packet.getStrings().read(0);
    int port = packet.getIntegers().read(1);
    request.setTarget(host, port);
}
 
Example 17
Source Project: helper   Source File: PacketScoreboardObjective.java    License: MIT License 5 votes vote down vote up
private PacketContainer newDisplaySlotPacket(DisplaySlot displaySlot) {
    // http://wiki.vg/Protocol#Display_Scoreboard
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);

    // set position
    final int slot;
    switch (displaySlot) {
        case PLAYER_LIST:
            slot = 0;
            break;
        case SIDEBAR:
            slot = 1;
            break;
        case BELOW_NAME:
            slot = 2;
            break;
        default:
            throw new RuntimeException();
    }

    packet.getIntegers().write(0, slot);

    // set objective name - The unique name for the scoreboard to be displayed.
    packet.getStrings().write(0, getId());

    return packet;
}
 
Example 18
Source Project: helper   Source File: PacketScoreboardTeam.java    License: MIT License 5 votes vote down vote up
private PacketContainer newRemovePacket() {
    // http://wiki.vg/Protocol#Teams
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);

    // remove packet only has the default fields

    // set team name - 	String (16)
    packet.getStrings().write(0, getId());

    // set mode - byte
    packet.getIntegers().write(GTEQ_1_13 ? 0 : 1, UpdateType.REMOVE.getCode());

    return packet;
}
 
Example 19
Source Project: NameTagChanger   Source File: ProtocolLibPacketHandler.java    License: MIT License 5 votes vote down vote up
@Override
public void sendTabListRemovePacket(Player playerToRemove, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
    packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
    PlayerInfoData playerInfoData = new PlayerInfoData(WrappedGameProfile.fromPlayer(playerToRemove), 0, EnumWrappers.NativeGameMode.NOT_SET, null);
    packet.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        logMessage(Level.SEVERE, "Failed to send tab list remove packet!", e);
    }
}
 
Example 20
Source Project: NameTagChanger   Source File: ProtocolLibPacketHandler.java    License: MIT License 5 votes vote down vote up
@Override
public void sendEntityDestroyPacket(Player playerToDestroy, Player seer) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_DESTROY);
    packet.getIntegerArrays().write(0, new int[] {playerToDestroy.getEntityId()});
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(seer, packet);
    } catch (InvocationTargetException e) {
        logMessage(Level.SEVERE, "Failed to send entity destroy packet!", e);
    }
}
 
Example 21
Source Project: NameTagChanger   Source File: ProtocolLibPacketHandler.java    License: MIT License 5 votes vote down vote up
private void doEquipmentPacketSend(int entityID, EnumWrappers.ItemSlot slot, ItemStack itemStack, Player recipient) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
    packet.getIntegers().write(0, entityID);
    packet.getItemSlots().write(0, slot);
    packet.getItemModifier().write(0, itemStack);
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(recipient, packet);
    } catch (InvocationTargetException e) {
        logMessage(Level.SEVERE, "Failed to send equipment packet!", e);
    }
}
 
Example 22
Source Project: NameTagChanger   Source File: ProtocolLibPacketHandler.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private PacketContainer getScoreboardPacket(String team, String entryToAdd, int mode) {
    PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
    packet.getStrings().write(0, team);
    packet.getIntegers().write(1, mode);
    ((Collection<String>) packet.getSpecificModifier(Collection.class).read(0)).add(entryToAdd);
    return packet;
}
 
Example 23
Source Project: UhcCore   Source File: ProtocolUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/***
 * This method can be used to change the tab header and footer.
 * @param player The player to change the header / footer for
 * @param header The new header
 * @param footer The new footer
 */
public static void setPlayerHeaderFooter(Player player, String header, String footer){
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
    packet.getChatComponents().write(0, WrappedChatComponent.fromText(header));
    packet.getChatComponents().write(1, WrappedChatComponent.fromText(footer));
    try {
        ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
    }catch (InvocationTargetException ex){
        ex.printStackTrace();
    }
}
 
Example 24
Source Project: VoxelGamesLibv2   Source File: AbstractPacket.java    License: MIT License 5 votes vote down vote up
/**
 * Constructs a new strongly typed wrapper for the given packet.
 *
 * @param handle - handle to the raw packet data.
 * @param type   - the packet type.
 */
protected AbstractPacket(PacketContainer handle, PacketType type) {
    // Make sure we're given a valid packet
    if (handle == null)
        throw new IllegalArgumentException("Packet handle cannot be NULL.");
    if (!Objects.equal(handle.getType(), type))
        throw new IllegalArgumentException(handle.getHandle()
                + " is not a packet of type " + type);

    this.handle = handle;
}
 
Example 25
Source Project: VoxelGamesLibv2   Source File: SkullPlaceHolders.java    License: MIT License 5 votes vote down vote up
public void init() {
    Bukkit.getPluginManager().registerEvents(this, voxelGamesLib);

    registerPlaceholders();

    // listener
    protocolManager.addPacketListener(new PacketAdapter(voxelGamesLib, PacketType.Play.Server.TILE_ENTITY_DATA) {
        @Override
        public void onPacketSending(PacketEvent event) {
            WrapperPlayServerTileEntityData packet = new WrapperPlayServerTileEntityData(event.getPacket());
            event.setPacket(modifySkull(packet, event.getPlayer()));
        }
    });

    // search for already loaded skulls
    Bukkit.getWorlds().stream()
            .flatMap(w -> Arrays.stream(w.getLoadedChunks()))
            .flatMap(s -> Arrays.stream(s.getTileEntities()))
            .filter(s -> s instanceof Skull)
            .map(s -> (Skull) s)
            .forEach(s -> lastSeenSkulls.put(s.getLocation(), s));

    // update task
    new BukkitRunnable() {

        @Override
        public void run() {
            lastSeenSkulls.forEach((loc, skull) -> skull.update());
        }
    }.runTaskTimer(voxelGamesLib, 20, 20);
}
 
Example 26
Source Project: AACAdditionPro   Source File: KeepAlive.java    License: GNU General Public License v3.0 5 votes vote down vote up
public KeepAlive()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOW,
          // --------------- Server --------------- //
          // KeepAlive analysis
          PacketType.Play.Server.KEEP_ALIVE,
          // --------------- Client --------------- //
          // KeepAlive analysis
          PacketType.Play.Client.KEEP_ALIVE);
}
 
Example 27
Source Project: AACAdditionPro   Source File: Inventory.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Inventory()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOWEST,
          // Look
          PacketType.Play.Client.LOOK,
          // Move
          PacketType.Play.Client.POSITION,
          PacketType.Play.Client.POSITION_LOOK);
}
 
Example 28
public PacketAnalysis()
{
    super(AACAdditionPro.getInstance(), ListenerPriority.LOW,
          // --------------- Server --------------- //
          // Compare
          PacketType.Play.Server.POSITION,
          // --------------- Client --------------- //
          // CombatOrder
          PacketType.Play.Client.USE_ENTITY,
          PacketType.Play.Client.ARM_ANIMATION,
          // EqualRotation
          PacketType.Play.Client.LOOK,
          // EqualRotation + Compare
          PacketType.Play.Client.POSITION_LOOK);
}
 
Example 29
/**
 * Constructs a new strongly typed wrapper for the given packet.
 *
 * @param handle - handle to the raw packet data.
 * @param type   - the packet type.
 */
protected AbstractPacket(PacketContainer handle, PacketType type)
{
    // Make sure we're given a valid packet
    Preconditions.checkNotNull(handle, "Packet handle cannot be NULL.");
    Preconditions.checkArgument(Objects.equal(handle.getType(), type), handle.getHandle() + " is not a packet of type " + type);
    this.handle = handle;
}
 
Example 30
Source Project: ChatItem   Source File: ChatPacketListener.java    License: GNU General Public License v3.0 5 votes vote down vote up
public ChatPacketListener(Plugin plugin, ListenerPriority listenerPriority, Storage s, PacketType... types) {
    super(plugin, listenerPriority, types);
    if(ChatItem.supportsShulkerBoxes()){
        SHULKER_BOXES.addAll(Arrays.asList(Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX,
                Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX,
                Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX,
                Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX,
                Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX));
    }
    c = s;
}