Skip to content

Instantly share code, notes, and snippets.

@mtbarr
Created February 10, 2023 22:36
Show Gist options
  • Save mtbarr/d2276c332bdf4a03d3d1a2fd4c0b8c6e to your computer and use it in GitHub Desktop.
Save mtbarr/d2276c332bdf4a03d3d1a2fd4c0b8c6e to your computer and use it in GitHub Desktop.
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
public class InternalPlayerPacketListener extends PacketAdapter implements Listener {
public InternalPlayerPacketListener(Plugin plugin) {
super(plugin,
PacketType.Play.Server.REL_ENTITY_MOVE,
PacketType.Play.Server.REL_ENTITY_MOVE_LOOK,
PacketType.Play.Server.ENTITY_VELOCITY,
PacketType.Play.Server.ENTITY_TELEPORT
);
}
@Override
public void onPacketSending(PacketEvent event) {
if (event.isAsync() || event.isAsynchronous()) {
return;
}
Player receiver = event.getPlayer();
int entityId = event.getPacket().getIntegers().read(0);
Entity entityFromID = ProtocolLibrary.getProtocolManager().getEntityFromID(receiver.getWorld(), entityId);
if (!(entityFromID instanceof Player)) {
return;
}
Player player = (Player) entityFromID;
// Hologram hologram = get players hologram
// hologram.teleport(player.getLocation().clone().add(0 , 2.1 , 0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment