Skip to content

Commit

Permalink
invisible command meta tweak and player online check
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 22, 2022
1 parent 0feae84 commit f2aac34
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -40,13 +40,16 @@ public InvisibleCommand() {
// @Group entity
//
// @Description
// Makes the specified entity invisible, defaults to the linked player/NPC if one wasn't specified.
// Makes the specified entity invisible (equivalent to an invisibility potion), defaults to the linked player/NPC if one wasn't specified.
// If an NPC was specified, the 'invisible' trait is applied.
//
// Optionally specify 'for:' with a list of players to fake the entity's visibility state for these players.
// When using the 'toggle' state with the 'for:' argument, the visibility state will be toggled for each player separately.
// Note that using the 'for:' argument won't apply the 'invisible' trait to NPCs.
// If unspecified, will be set globally.
// 'For' players remain tracked even when offline/reconnecting, but are forgotten after server restart.
// Note that using the 'for:' argument won't apply the 'invisible' trait to NPCs.
//
// When not using 'for', the effect is global / on the real entity, which will persist in that entity's data until changed.
//
// To reset an entity's fake visibility use the 'reset' state.
// A reset is global by default, use the 'for:' argument to reset specific players.
Expand Down Expand Up @@ -121,7 +124,7 @@ public static void setInvisibleForPlayer(EntityTag target, PlayerTag player, boo
HashMap<UUID, Boolean> playerMap = invisibleEntities.computeIfAbsent(target.getUUID(), k -> new HashMap<>());
wasModified = !playerMap.containsKey(player.getUUID()) || playerMap.get(player.getUUID()) != invisible || wasModified;
playerMap.put(player.getUUID(), invisible);
if (wasModified) {
if (wasModified && player.isOnline()) {
NMSHandler.packetHelper.sendEntityMetadataFlagsUpdate(player.getPlayerEntity(), target.getBukkitEntity());
}
}
Expand Down

0 comments on commit f2aac34

Please sign in to comment.