Class GroupHelper

java.lang.Object
com.mrbysco.armorposer.client.GroupHelper

public class GroupHelper extends Object
Manages groups of armor stands for the Armor Poser mod. Each group is identified by a unique name and contains a list of armor stand UUIDs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Map<String, net.minecraft.ChatFormatting>
     
    static final List<String>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addToGroup(String groupName, net.minecraft.world.entity.decoration.ArmorStand armorStand)
    Adds an armor stand to a specified group.
    static void
    addToGroupLocal(String groupName, UUID armorStandId)
    Adds an armor stand to a specified group without sending an update packet.
    static void
    clearGroup(String groupName, net.minecraft.world.level.Level level)
    Clears all armor stands from a specified group and updates the entities in the provided level accordingly.
    static net.minecraft.ChatFormatting
    Retrieves the chat formatting color associated with a specified group name.
    static List<UUID>
    getGroup(String groupName)
    Retrieves the list of armor stand UUIDs associated with a specified group.
    static List<String>
    Retrieves a list of group names that a specified armor stand belongs to.
    static boolean
    isEmpty(String group)
    Checks if a specified group is empty, meaning it has no armor stands associated with it.
    static boolean
    isInGroup(String group, UUID uuid)
    Checks if a specified armor stand is part of a specified group.
    static void
    loadGroups(net.minecraft.world.entity.decoration.ArmorStand armorStand)
    Loads the group information for a specified armor stand from its custom data and updates the group map accordingly.
    static void
    Removes any armor stands from all groups that are not present in the provided set of valid UUIDs.
    static void
    removeFromGroup(String groupName, net.minecraft.world.entity.decoration.ArmorStand armorStand)
    Removes an armor stand from a specified group.
    static void
    saveGroups(net.minecraft.world.entity.decoration.ArmorStand armorStand, List<String> groups)
    Saves the group information for a specified armor stand to its custom data.
    static void
    syncGroups(Map<UUID, List<String>> serverGroups)
    Synchronizes the group information for all armor stands with the provided server group data.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_GROUP_MAP

      public static final Map<String, net.minecraft.ChatFormatting> DEFAULT_GROUP_MAP
    • DEFAULT_GROUP_NAMES

      public static final List<String> DEFAULT_GROUP_NAMES
  • Constructor Details

    • GroupHelper

      public GroupHelper()
  • Method Details

    • addToGroup

      public static void addToGroup(String groupName, net.minecraft.world.entity.decoration.ArmorStand armorStand)
      Adds an armor stand to a specified group. If the group does not exist, it will be created.
      Parameters:
      groupName - the name of the group to add the armor stand to
      armorStand - the armor stand to add to the group
    • addToGroupLocal

      public static void addToGroupLocal(String groupName, UUID armorStandId)
      Adds an armor stand to a specified group without sending an update packet. This is used for local updates when loading group information from an armor stand's custom data.
      Parameters:
      groupName - the name of the group to add the armor stand to
      armorStandId - the UUID of the armor stand to add to the group
    • removeFromGroup

      public static void removeFromGroup(String groupName, net.minecraft.world.entity.decoration.ArmorStand armorStand)
      Removes an armor stand from a specified group. If the group becomes empty after removal, it will be deleted.
      Parameters:
      groupName - the name of the group to remove the armor stand from
      armorStand - the armor stand to remove from the group
    • getGroupsForArmorStand

      public static List<String> getGroupsForArmorStand(UUID armorStandId)
      Retrieves a list of group names that a specified armor stand belongs to.
      Parameters:
      armorStandId - the UUID of the armor stand to check for group membership
      Returns:
      a list of group names that the armor stand belongs to, or an empty list if the armor stand does not belong to any groups
    • getFormatForGroup

      public static net.minecraft.ChatFormatting getFormatForGroup(String groupName)
      Retrieves the chat formatting color associated with a specified group name.
      Parameters:
      groupName - the name of the group to retrieve the chat formatting color for
      Returns:
      the chat formatting color associated with the group name, or WHITE if the group name is not found in the default group map
    • getGroup

      public static List<UUID> getGroup(String groupName)
      Retrieves the list of armor stand UUIDs associated with a specified group.
      Parameters:
      groupName - the name of the group to retrieve
      Returns:
      a list of UUIDs for the armor stands in the group, or an empty list if the group does not exist
    • clearGroup

      public static void clearGroup(String groupName, net.minecraft.world.level.Level level)
      Clears all armor stands from a specified group and updates the entities in the provided level accordingly.
      Parameters:
      groupName - the name of the group to clear
      level - the level containing the entities to update after clearing the group
    • isInGroup

      public static boolean isInGroup(String group, UUID uuid)
      Checks if a specified armor stand is part of a specified group.
      Parameters:
      group - the name of the group to check
      uuid - the UUID of the armor stand to check for membership in the group
      Returns:
      true if the armor stand is part of the group, false otherwise
    • pruneInvalid

      public static void pruneInvalid(Set<UUID> valid)
      Removes any armor stands from all groups that are not present in the provided set of valid UUIDs.
      Parameters:
      valid - a set of valid armor stand UUIDs to retain in the groups
    • isEmpty

      public static boolean isEmpty(String group)
      Checks if a specified group is empty, meaning it has no armor stands associated with it.
      Parameters:
      group - the name of the group to check for emptiness
      Returns:
      true if the group is empty or does not exist, false if the group has one or more armor stands associated with it
    • loadGroups

      public static void loadGroups(net.minecraft.world.entity.decoration.ArmorStand armorStand)
      Loads the group information for a specified armor stand from its custom data and updates the group map accordingly.
      Parameters:
      armorStand - the armor stand to load the group information for
    • saveGroups

      public static void saveGroups(net.minecraft.world.entity.decoration.ArmorStand armorStand, List<String> groups)
      Saves the group information for a specified armor stand to its custom data. If the group information has not changed, it will not update the custom data.
      Parameters:
      armorStand - the armor stand to save the group information for
      groups - the list of group names that the armor stand belongs to
    • syncGroups

      public static void syncGroups(Map<UUID, List<String>> serverGroups)
      Synchronizes the group information for all armor stands with the provided server group data. This will clear the existing group map and repopulate it based on the server data.
      Parameters:
      serverGroups - a map of armor stand UUIDs to lists of group names that they belong to, representing the current group information from the server