Skip to Content

Totem Counter Module

Overview

The totem counter module allows servers to control the totem pops displayed by the Totem Counter mod.

  • Adds the ability to override the totem pops of any player, shown on their nametag, tab list entry and the Totem Counter HUD.
    • Display totem pops the client can’t track on its own, such as pops outside of tracking range or before the player joined.
    • Ability to stop the client from tracking and resetting totem pops on its own.

An overridden totem counter replaces the client’s own count for that player, and the client keeps counting on top of it unless DISABLE_LOCAL_TRACKING is enabled.

This module is only supported for 1.12 and above versions of Lunar Client.

The Totem Counter mod is disabled by default, totem counters sent while it is disabled are ignored. See the Totem Counter mod page to enable it for your players.

Integration

Enable DISABLE_LOCAL_TRACKING when sending every totem pop, otherwise the client also counts each pop and shows one more.

Sample Code

Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

Apollo API examples. See General for common patterns and helpers.

Overriding a Totem Counter

public void overrideTotemCounterExample(Player viewer) { Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> { this.totemCounterModule.overrideTotemCounter(apolloPlayer, TotemCounter.builder() .playerUuid(viewer.getUniqueId()) .pops(3) .build() ); }); }

Overriding multiple Totem Counters

public void overrideTotemCountersExample(Player viewer) { Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> { List<TotemCounter> totemCounters = Bukkit.getOnlinePlayers() .stream().map(player -> TotemCounter.builder() .playerUuid(player.getUniqueId()) .pops(2) .build()) .collect(Collectors.toList()); this.totemCounterModule.overrideTotemCounters(apolloPlayer, totemCounters); }); }

Resetting a Totem Counter

The client forgets the player’s totem pops, including the ones it tracked on its own.

public void resetTotemCounterExample(Player viewer) { Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(apolloPlayer -> this.totemCounterModule.resetTotemCounter(apolloPlayer, viewer.getUniqueId())); }

Resetting all Totem Counters

The client forgets every player’s totem pops, including the ones it tracked on its own.

public void resetTotemCountersExample(Player viewer) { Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId()); apolloPlayerOpt.ifPresent(this.totemCounterModule::resetTotemCounters); }

Tracking Totem Pops

private final Map<UUID, Integer> totemPops = new ConcurrentHashMap<>(); @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) private void onEntityResurrect(EntityResurrectEvent event) { if (!(event.getEntity() instanceof Player)) { return; } Player player = (Player) event.getEntity(); int pops = this.totemPops.merge(player.getUniqueId(), 1, Integer::sum); // Pops are absolute, send the new total instead of an increment this.totemCounterModule.overrideTotemCounter(Recipients.ofEveryone(), TotemCounter.builder() .playerUuid(player.getUniqueId()) .pops(pops) .build() ); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) private void onPlayerDeath(PlayerDeathEvent event) { this.resetTotemPops(event.getEntity()); } @EventHandler private void onPlayerQuit(PlayerQuitEvent event) { this.resetTotemPops(event.getPlayer()); } private void resetTotemPops(Player player) { if (this.totemPops.remove(player.getUniqueId()) != null) { this.totemCounterModule.resetTotemCounter(Recipients.ofEveryone(), player.getUniqueId()); } }

Toggle Local Tracking

public void setDisableLocalTracking(boolean value) { this.totemCounterModule.getOptions().set(TotemCounterModule.DISABLE_LOCAL_TRACKING, value); }

overrideTotemCounter & overrideTotemCounters Parameters

  1. Recipients recipients
    • A list of all the player(s) you want to be able to see the updated totem counters.
  2. TotemCounter totemCounter or Collection<TotemCounter> totemCounters

resetTotemCounter Parameters

  1. Recipients recipients
    • A list of all the player(s) you want to be able to see the updated totem counter.
  2. UUID playerUuid, TotemCounter totemCounter or Collection<UUID> playerUuids
    • The player(s) you want to reset the totem counter of.

TotemCounter Options

.playerUuid(UUID) is the player, by UUID, that you wish to apply the totem counter to. Sending a totem counter for an already known player replaces that player’s pops.

.playerUuid(viewer.getUniqueId())

.pops(Integer) is the amount of totems the player has popped. Values are absolute, not increments, so sending the same value twice is harmless. The client keeps counting from this value, unless DISABLE_LOCAL_TRACKING is enabled.

.pops(3)

Available options

  • DISABLE_LOCAL_TRACKING
    • Whether the client stops tracking and resetting totem pops on its own.
    • Values
      • Type: Boolean
      • Default: false