Class GroupManager

java.lang.Object
com.jackdaw.chatwithnpc.group.GroupManager

public class GroupManager extends Object
This class is used to manage the groups of the game.
  • Field Details

  • Constructor Details

    • GroupManager

      public GroupManager()
  • Method Details

    • isLoaded

      public static boolean isLoaded(String name)
    • loadGroup

      public static void loadGroup(String name, boolean canCreate)
      Initialize a group if the group is not loaded.
      Parameters:
      name - The name of the group
    • discardGroup

      public static void discardGroup(String name)
      Discard a group from the group map.
      Parameters:
      name - The name of the group
    • getGroup

      @Nullable public static @Nullable Group getGroup(String name)
      Get the group by the name.
      Parameters:
      name - The name of the group
      Returns:
      The group
    • endOutOfTimeGroup

      public static void endOutOfTimeGroup()
      Discard the groups that have not been load for a long time.
    • endAllGroup

      public static void endAllGroup()
      Discard all the groups.
    • getParentGroups

      @NotNull public static @NotNull ArrayList<Group> getParentGroups(@NotNull @NotNull String currentGroup)
      Get all the parent groups of the group. Include the group itself.
      Parameters:
      currentGroup - the parent group of the group.
      Returns:
      parentGroups the parent groups of the group.
    • getGroupList

      @NotNull public static @NotNull ArrayList<String> getGroupList()
      Get the list of the groups from the files.
      Returns:
      The list of the groups.
    • addGroupMember

      public static void addGroupMember(String groupName, String member)
      Add a member to the group, and all the parent groups.
      Parameters:
      groupName - The name of the group
      member - The name of the member
    • removeGroupMember

      public static void removeGroupMember(String groupName, String member)
      Remove a member from the group, and all the parent groups.
      Parameters:
      groupName - The name of the group
      member - The name of the member
    • setGroupParent

      public static void setGroupParent(String groupName, String newParentName)
      Set the parent group of the group. And move all the members to the new parent group.
      Parameters:
      groupName - The name of the group
      newParentName - The name of the new parent group
    • getGroupsPrompt

      @NotNull public static @NotNull String getGroupsPrompt(String group)
      Get the prompt of the group and all the parent groups.
      Parameters:
      group - the group name
      Returns:
      the prompt of the group
    • getGroupTree

      @NotNull public static @NotNull String getGroupTree(String root)
      Get the group tree.
      Parameters:
      root - The root of the tree
      Returns:
      The group tree