Skip to content

Commit

Permalink
misc: cancel spawn packet if player has an active disguise
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Dec 13, 2023
1 parent cf05071 commit 95d3440
Showing 1 changed file with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -307,11 +307,42 @@ private void refreshStateForPlayer(@Nullable Player player, @NotNull DisplayPara

var parametersFinal = new DisplayParameters(gameProfile, parameters.playerDisguiseName(), parameters.bukkitType(), parameters.watcher());
var spawnPackets = buildSpawnPackets(player, parametersFinal);
/*
var delayedPackets = new ObjectArrayList<PacketContainer>();
spawnPackets.forEach(packet ->
{
if (packet.getMeta("delayed").isPresent())
delayedPackets.add(packet);
});
spawnPackets.removeAll(delayedPackets);
*/
spawnPackets.forEach(packet ->
{
for (var visiblePlayer : affectedPlayers)
protocolManager.sendServerPacket(visiblePlayer, packet);
});
/*
if (!delayedPackets.isEmpty())
{
var registryParameters = registry.getParameters(player.getUniqueId());
this.addSchedule(() ->
{
var parametersNew = registry.getParameters(player.getUniqueId());
if (parametersNew != registryParameters) return;
delayedPackets.forEach(packet ->
{
for (var affectedPlayer : affectedPlayers)
protocolManager.sendServerPacket(affectedPlayer, packet);
});
}, 1);
}
*/
}

private void onEntityAddPacket(ClientboundAddEntityPacket packet, PacketEvent packetEvent)
@@ -329,8 +360,15 @@ private void onEntityAddPacket(ClientboundAddEntityPacket packet, PacketEvent pa
modifier.write(2, entityType);

var meta = packetContainer.getMeta("fm");
if (meta.isPresent()) packetContainer.removeMeta("fm");
else refreshStateForPlayer(Bukkit.getPlayer(packet.getUUID()));
if (meta.isPresent())
{
packetContainer.removeMeta("fm");
}
else
{
packetEvent.setCancelled(true);
refreshStateForPlayer(Bukkit.getPlayer(packet.getUUID()));
}
}

@Override

0 comments on commit 95d3440

Please sign in to comment.