-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 16 additions & 13 deletions
29
src/main/java/eu/decentsoftware/holograms/api/nms/PacketHandler__ProtocolLib.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
package eu.decentsoftware.holograms.api.nms; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.ProtocolLibrary; | ||
import com.comphenix.protocol.ProtocolManager; | ||
import com.comphenix.protocol.events.ListenerPriority; | ||
import com.comphenix.protocol.events.PacketAdapter; | ||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.events.PacketEvent; | ||
import eu.decentsoftware.holograms.api.DecentHologramsAPI; | ||
import org.bukkit.entity.Player; | ||
|
||
public class PacketHandler__ProtocolLib extends PacketAdapter { | ||
public class PacketHandler__ProtocolLib { | ||
|
||
public PacketHandler__ProtocolLib() { | ||
super(DecentHologramsAPI.get().getPlugin(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY); | ||
} | ||
|
||
@Override | ||
public void onPacketReceiving(PacketEvent event) { | ||
if (event.getPacketType().equals(PacketType.Play.Client.USE_ENTITY)) { | ||
PacketContainer packetContainer = event.getPacket(); | ||
Object packet = packetContainer.getHandle(); | ||
Player player = event.getPlayer(); | ||
if (PacketHandlerCommon.handlePacket(packet, player)) { | ||
event.setCancelled(true); | ||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); | ||
protocolManager.addPacketListener(new PacketAdapter(DecentHologramsAPI.get().getPlugin(), ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) { | ||
@Override | ||
public void onPacketReceiving(PacketEvent event) { | ||
if (event.getPacketType().equals(PacketType.Play.Client.USE_ENTITY)) { | ||
PacketContainer packetContainer = event.getPacket(); | ||
Object packet = packetContainer.getHandle(); | ||
Player player = event.getPlayer(); | ||
if (PacketHandlerCommon.handlePacket(packet, player)) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
} |