java.lang.Object
org.geysermc.floodgate.core.platform.command.CommandUtil

public abstract class CommandUtil extends Object
An interface used across all Floodgate platforms to simple stuff in commands like kicking players and sending player messages independent of the Floodgate platform implementation.
  • Field Details

    • manager

      protected final LanguageManager manager
    • api

      protected final org.geysermc.api.GeyserApiBase api
  • Constructor Details

    • CommandUtil

      protected CommandUtil(LanguageManager manager, org.geysermc.api.GeyserApiBase api)
  • Method Details

    • getUserAudience

      public abstract @NonNull UserAudience getUserAudience(@NonNull Object source)
    • getProfileAudience

      public @Nullable ProfileAudience getProfileAudience(@NonNull Object source, boolean allowOffline)
      Get a ProfileAudience from a source. The source should be a platform-specific player instance when the player is online, and the username / uuid of the requested player when offline.
      Parameters:
      source - source to create a ProfileAudience from
      allowOffline - if offline players are allowed
      Returns:
      a ProfileAudience unless allowOffline is false and the player isn't online
    • getUsernameFromSource

      protected abstract String getUsernameFromSource(@NonNull Object source)
    • getUuidFromSource

      protected abstract UUID getUuidFromSource(@NonNull Object source)
    • getOnlinePlayers

      protected abstract Collection<?> getOnlinePlayers()
    • getOnlineUsernames

      public @NonNull List<String> getOnlineUsernames(@NonNull PlayerType limitTo)
    • getPlayerByUuid

      public abstract Object getPlayerByUuid(@NonNull UUID uuid)
      Parameters:
      uuid -
      Returns:
    • getPlayerByUuid

      public Object getPlayerByUuid(@NonNull UUID uuid, PlayerType limitTo)
    • getPlayerByUsername

      public abstract Object getPlayerByUsername(@NonNull String username)
    • getPlayerByUsername

      public Object getPlayerByUsername(@NonNull String username, PlayerType limitTo)
    • applyPlayerTypeFilter

      protected Object applyPlayerTypeFilter(Object player, PlayerType filter, Object fallback)
    • hasPermission

      public abstract boolean hasPermission(Object player, String permission)
      Checks if the given player has the given permission.
      Parameters:
      player - the player to check
      permission - the permission to check
      Returns:
      true or false depending on if the player has the permission
    • sendMessage

      public abstract void sendMessage(Object target, String message)
      Sends a raw message to the specified target, no matter what platform Floodgate is running on.
      Parameters:
      target - the player that should receive the message
      message - the message
    • kickPlayer

      public abstract void kickPlayer(Object player, String message)
      Kicks the given player using the given message as the kick reason.
      Parameters:
      player - the player that should be kicked
      message - the command message
    • translateMessage

      public String translateMessage(String locale, TranslatableMessage message, Object... args)
    • whitelistPlayer

      public boolean whitelistPlayer(long xuid, String username)
      Whitelist the given Bedrock player.
      Parameters:
      xuid - the xuid of the username to be whitelisted
      username - the username to be whitelisted
      Returns:
      true if the player has been whitelisted, false if the player was already whitelisted. Defaults to false when this platform doesn't support whitelisting.
    • whitelistPlayer

      public boolean whitelistPlayer(UUID uuid, String username)
      Whitelist the given Bedrock player.
      Parameters:
      uuid - the UUID of the username to be whitelisted
      username - the username to be whitelisted
      Returns:
      true if the player has been whitelisted, false if the player was already whitelisted. Defaults to false when this platform doesn't support whitelisting.
    • removePlayerFromWhitelist

      public boolean removePlayerFromWhitelist(long xuid, String username)
      Removes the given Bedrock player from the whitelist.
      Parameters:
      xuid - the xuid of the username to be removed from the whitelist
      username - the username to be removed from the whitelist
      Returns:
      true if the player has been removed from the whitelist, false if the player wasn't whitelisted. Defaults to false when this platform doesn't support whitelisting.
    • removePlayerFromWhitelist

      public boolean removePlayerFromWhitelist(UUID uuid, String username)
      Removes the given Bedrock player from the whitelist.
      Parameters:
      uuid - the UUID of the username to be removed from the whitelist
      username - the username to be removed from the whitelist
      Returns:
      true if the player has been removed from the whitelist, false if the player wasn't whitelisted. Defaults to false when this platform doesn't support whitelisting.