Class PartyHandler

  • All Implemented Interfaces:
    org.bukkit.event.Listener

    public class PartyHandler
    extends Mechanic
    Handles party saving, loading, and storage.
    • Constructor Detail

      • PartyHandler

        public PartyHandler()
    • Method Detail

      • onStartup

        public void onStartup()
        Description copied from class: Mechanic
        Runs when the plugin is being enabled.
        Overrides:
        onStartup in class Mechanic
      • onShutdown

        public void onShutdown()
        Runs on plugin shutdown. Save parties if persistent parties is enabled.
        Overrides:
        onShutdown in class Mechanic
      • loadParties

        public void loadParties()
        Load parties from JSON file storage.
      • saveParty

        public void saveParty​(Party party)
        Save a party to the JSON file storage.
        Parameters:
        party - Party so save.
      • deleteParty

        public void deleteParty​(Party party)
        Delete a party from the JSON file storage.
        Parameters:
        party - Party to delete.
      • isNameTaken

        public boolean isNameTaken​(String name)
        Check if a certain party name is already taken.
        Parameters:
        name - Name to check.
        Returns:
        true if taken | false if free
      • getParty

        @Nullable
        public @Nullable Party getParty​(User user)
        Get a party from a User. May be null if the user is not in a party.
        Parameters:
        user - User to get party from.
        Returns:
        Party, if it exists.
      • getParty

        @Nullable
        public @Nullable Party getParty​(UUID uuid)
        Get a party from a party unique id. May be null if the party doesn't exist.
        Parameters:
        uuid - Party's unique id.
        Returns:
        Party, if it exists.
      • getParty

        @Nullable
        public @Nullable Party getParty​(org.bukkit.entity.Player player)
        Get a party from a player. May be null if the player is not in a party.
        Parameters:
        player - Player to get party from.
        Returns:
        Party, if it exists.
      • getParties

        public List<Party> getParties()
        Get a list of all active parties.
        Returns:
        All active parties.
      • getPartyMap

        public Map<UUID,​Party> getPartyMap()
        Get main party map.
        Returns:
        the map
      • addToPartyMap

        public void addToPartyMap​(UUID uuid,
                                  Party party)
        Add a party id and the party to the party map.
        Parameters:
        uuid - The party's unique id.
        party - The party to add.
      • removeFromPartyMap

        public void removeFromPartyMap​(UUID uuid)
        Remove a player from the party map.
        Parameters:
        uuid - The unique id of the player to remove.
      • sendMessageToPartyChat

        public void sendMessageToPartyChat​(Party party,
                                           User sender,
                                           String message)
        Send a message to a party. This will fire the PartyChatEvent.
        Parameters:
        party - The party to send the message to.
        sender - The User sending the message.
        message - The message being sent.