Class PrivateGamesAPI

java.lang.Object
me.harsh.privategamesaddon.api.PrivateGamesAPI

public class PrivateGamesAPI extends Object
Base API class for the Private Games Addon.
  • Method Details

    • isPrivateArena

      public boolean isPrivateArena(Arena arena)
      Get whether the arena is set to private.

      A private arena only allows players from a specific party to join.

      Parameters:
      arena - The arena to check
      Returns:
      true if the arena is private, false otherwise
      See Also:
    • isPrivateArena

      public boolean isPrivateArena(RemoteArena arena)
      Get whether the arena is set to private.

      A private arena only allows players from a specific party to join.

      Due to the nature of RemoteArenas, it may be slightly desynced compared to the local Arena instance (isPrivateArena(Arena)).

      Parameters:
      arena - The arena to check
      Returns:
      true if the arena is private, false otherwise
      See Also:
    • getManagingParty

      @Nullable public @Nullable PartiesHook.Party getManagingParty(Arena arena)
      Get the party managing the private arena.
      Parameters:
      arena - The arena to check
      Returns:
      The managing party, or null if the arena is not private
      See Also:
    • unsetPrivateArena

      public void unsetPrivateArena(Arena arena)
      Unset the private status of an arena.

      With that, anyone can join the arena again and buff effects will be removed.

      Parameters:
      arena - The arena to unset
      See Also:
    • setPrivateArena

      public void setPrivateArena(Arena arena, PartiesHook.Party party)
      Set an arena to private for a specific party.

      Does not automatically kick players not part of the party.

      Parameters:
      arena - The arena to set
      party - The party allowed to join
      See Also:
    • getBuffState

      @Nullable public @Nullable ArenaBuffState getBuffState(Arena arena)
      Get the buff state for a specific arena.
      Parameters:
      arena - The arena to get the buff state for
      Returns:
      The arena buff state, or null if the arena is not private
    • hasPrivateModeEnabled

      public boolean hasPrivateModeEnabled(PlayerProperties playerProps)
      Check if a player has private mode enabled.

      May not be absolutely accurate in certain situations if player is not online, but should be fine for most use-cases.

      Parameters:
      playerProps - The player properties to check
      Returns:
      true if private mode is enabled, false otherwise
    • hasPrivateModeEnabled

      public void hasPrivateModeEnabled(Player player, Consumer<Boolean> callback)
      Check if a player has private mode enabled.

      Callback is executed on the server's main thread.

      Parameters:
      player - The player to check
      callback - The callback to execute with the result
    • setPrivateModeEnabled

      public void setPrivateModeEnabled(PlayerProperties playerProps, boolean newState)
      Enable or disable private mode for a player.

      hasPrivateModeEnabled(PlayerProperties) might return false regardless it is enabled if the player does not have the permission (see hasCreatePermission(Permissible)).

      Parameters:
      playerProps - The player properties to set
      newState - true to enable, false to disable
    • setPrivateModeEnabled

      public void setPrivateModeEnabled(Player player, boolean newState, @Nullable @Nullable Runnable callback)
      Enable or disable private mode for a player.

      hasPrivateModeEnabled(Player, Consumer) might return false regardless it is enabled if the player does not have the permission (see hasCreatePermission(Permissible)).

      Callback is executed on the server's main thread.

      Parameters:
      player - The player to set
      newState - true to enable, false to disable
      callback - The callback to execute after setting (can be null if not needed)
    • hasCreatePermission

      public boolean hasCreatePermission(Permissible player)
      Check if a player has permission to create private games.
      Parameters:
      player - The player to check
      Returns:
      true if the player has permission, false otherwise
    • get

      public static PrivateGamesAPI get()
      Get the global instance of PrivateGamesAPI.
      Returns:
      The PrivateGamesAPI instance