Class VelocityResourcepacks

java.lang.Object
de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks
All Implemented Interfaces:
ResourcepacksPlugin, de.themoep.utils.lang.velocity.Languaged

public class VelocityResourcepacks extends Object implements ResourcepacksPlugin, de.themoep.utils.lang.velocity.Languaged
  • Field Details

    • PLUGIN_MESSAGE_CHANNEL

      public static final com.velocitypowered.api.proxy.messages.ChannelIdentifier PLUGIN_MESSAGE_CHANNEL
    • pluginCommand

      protected ResourcepacksPluginCommandExecutor pluginCommand
  • Constructor Details

    • VelocityResourcepacks

      @Inject public VelocityResourcepacks(com.velocitypowered.api.proxy.ProxyServer proxy, org.slf4j.Logger logger, Path dataFolder)
  • Method Details

    • onProxyInitialization

      public void onProxyInitialization(com.velocitypowered.api.event.proxy.ProxyInitializeEvent event)
    • registerCommand

      protected void registerCommand(PluginCommandExecutor executor)
    • loadConfig

      public boolean loadConfig()
      Specified by:
      loadConfig in interface ResourcepacksPlugin
    • getConfigMap

      public Map<String,​Object> getConfigMap(Object configuration)
      Description copied from interface: ResourcepacksPlugin
      Convert a configuration object to a map
      Specified by:
      getConfigMap in interface ResourcepacksPlugin
      Parameters:
      configuration - The configuration object
      Returns:
      The configuration map or null if input was null or is not supported
    • reloadConfig

      public void reloadConfig(boolean resend)
      Reloads the configuration from the file and resends the resource pack to all online players
      Specified by:
      reloadConfig in interface ResourcepacksPlugin
      Parameters:
      resend - Whether or not all players should get their applicable pack resend
    • saveConfigChanges

      public void saveConfigChanges()
      Description copied from interface: ResourcepacksPlugin
      Save changes made on runtime to the config
      Specified by:
      saveConfigChanges in interface ResourcepacksPlugin
    • setStoredPack

      public void setStoredPack(UUID playerId, String packName)
      Description copied from interface: ResourcepacksPlugin
      Set the pack that the player should get when logging in when no other pack applies and that gets used instead of the empty pack on reset
      Specified by:
      setStoredPack in interface ResourcepacksPlugin
      Parameters:
      playerId - UUID of the player
      packName - Name of the pack
    • getStoredPack

      public String getStoredPack(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Get the pack that a certain player has stored
      Specified by:
      getStoredPack in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      Returns:
      The name of the pack or null if none was stored
    • getStoredPacks

      public ninja.leaping.configurate.ConfigurationNode getStoredPacks()
    • isUsepackTemporary

      public boolean isUsepackTemporary()
      Description copied from interface: ResourcepacksPlugin
      Get whether or not the default /usepack behaviour is to apply temporary opr permanent
      Specified by:
      isUsepackTemporary in interface ResourcepacksPlugin
      Returns:
      true if it's temporary, false if not
    • getPermanentPackRemoveTime

      public int getPermanentPackRemoveTime()
      Description copied from interface: ResourcepacksPlugin
      Get the time in which the permanent pack will be reset if the player disconnects
      Specified by:
      getPermanentPackRemoveTime in interface ResourcepacksPlugin
      Returns:
      The time in seconds; 0 or below should disable that
    • getConfig

      public PluginConfig getConfig()
    • isEnabled

      public boolean isEnabled()
      Get whether the plugin successful enabled or not
      Specified by:
      isEnabled in interface ResourcepacksPlugin
      Returns:
      Whether or not the plugin was enabled
    • resendPack

      public void resendPack(com.velocitypowered.api.proxy.Player player)
      Resends the pack that corresponds to the player's server
      Parameters:
      player - The player to set the pack for
    • resendPack

      public void resendPack(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Resends the pack that corresponds to the player's server
      Specified by:
      resendPack in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player to resend the pack for
    • sendPack

      protected void sendPack(com.velocitypowered.api.proxy.Player player, ResourcePack pack)
      Send a resourcepack to a connected player
      Parameters:
      player - The Player to send the pack to
      pack - The resourcepack to send the pack to
    • sendPackInfo

      public void sendPackInfo(com.velocitypowered.api.proxy.Player player, ResourcePack pack)

      Send a plugin message to the server the player is connected to!

      Channel: Resourcepack

      sub-channel: packChange

      arg1: player.getName()

      arg2: pack.getName();

      arg3: pack.getUrl();

      arg4: pack.getHash();

      Parameters:
      player - The player to update the pack on the player's bukkit server
      pack - The ResourcePack to send the info of the the Bukkit server, null if you want to clear it!
    • setPack

      public void setPack(UUID playerId, ResourcePack pack)
      Description copied from interface: ResourcepacksPlugin
      Set the resoucepack of a connected player
      Specified by:
      setPack in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player to set the pack for
      pack - The resourcepack to set for the player
    • sendPack

      public void sendPack(UUID playerId, ResourcePack pack)
      Description copied from interface: ResourcepacksPlugin
      Internal method to send a resoucepack to a player, please use PackManager.setPack(UUID, ResourcePack)!
      Specified by:
      sendPack in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player to send the pack to
      pack - The resourcepack to send to a player
    • clearPack

      public void clearPack(com.velocitypowered.api.proxy.Player player)
    • clearPack

      public void clearPack(UUID playerId)
      Specified by:
      clearPack in interface ResourcepacksPlugin
    • getPackManager

      public PackManager getPackManager()
      Specified by:
      getPackManager in interface ResourcepacksPlugin
    • getUserManager

      public UserManager getUserManager()
      Specified by:
      getUserManager in interface ResourcepacksPlugin
    • setBackend

      public void setBackend(UUID playerId)
      Add a player's UUID to the list of players with a backend pack
      Parameters:
      playerId - The uuid of the player
    • unsetBackend

      public void unsetBackend(UUID playerId)
      Remove a player's UUID from the list of players with a backend pack
      Parameters:
      playerId - The uuid of the player
    • hasBackend

      public boolean hasBackend(UUID playerId)
      Check if a player has a pack set by a backend server
      Parameters:
      playerId - The UUID of the player
      Returns:
      If the player has a backend pack
    • getMessage

      public String getMessage(ResourcepacksPlayer sender, String key, String... replacements)
      Description copied from interface: ResourcepacksPlugin
      Get a message from the language config
      Specified by:
      getMessage in interface ResourcepacksPlugin
      Parameters:
      sender - The sender to get the message from, will use the client language if available
      key - The message key
      replacements - Optional placeholder replacement array
      Returns:
      The message or an error message if not available, never null
    • getComponents

      public net.kyori.adventure.text.Component getComponents(ResourcepacksPlayer sender, String key, String... replacements)
      Get message components from the language config
      Parameters:
      sender - The sender to get the message from, will use the client language if available
      key - The message key
      replacements - Optional placeholder replacement array
      Returns:
      The components or an error message if not available, never null
    • hasMessage

      public boolean hasMessage(ResourcepacksPlayer sender, String key)
      Description copied from interface: ResourcepacksPlugin
      Check whether or not the language config contains a certain message
      Specified by:
      hasMessage in interface ResourcepacksPlugin
      Parameters:
      sender - The sender
      key - The message key
      Returns:
      true if the config contains the message; false if not
    • getName

      public String getName()
      Description copied from interface: ResourcepacksPlugin
      Get the name of the plugin
      Specified by:
      getName in interface de.themoep.utils.lang.velocity.Languaged
      Specified by:
      getName in interface ResourcepacksPlugin
      Returns:
      The plugin's name as a string
    • getVersion

      public String getVersion()
      Description copied from interface: ResourcepacksPlugin
      Get the version of the plugin
      Specified by:
      getVersion in interface ResourcepacksPlugin
      Returns:
      The plugin's version as a string
    • getProxy

      public com.velocitypowered.api.proxy.ProxyServer getProxy()
    • getPluginLogger

      public PluginLogger getPluginLogger()
      Specified by:
      getPluginLogger in interface ResourcepacksPlugin
    • getLangLogger

      public de.themoep.utils.lang.LangLogger getLangLogger()
      Specified by:
      getLangLogger in interface de.themoep.utils.lang.velocity.Languaged
    • getDataFolder

      public File getDataFolder()
      Specified by:
      getDataFolder in interface de.themoep.utils.lang.velocity.Languaged
      Specified by:
      getDataFolder in interface ResourcepacksPlugin
    • getDescription

      public com.velocitypowered.api.plugin.PluginDescription getDescription()
    • logDebug

      public void logDebug(String message)
      Description copied from interface: ResourcepacksPlugin
      Log a debug message
      Specified by:
      logDebug in interface ResourcepacksPlugin
      Parameters:
      message - The message
    • logDebug

      public void logDebug(String message, Throwable throwable)
      Description copied from interface: ResourcepacksPlugin
      Log a debug message with a stacktrace
      Specified by:
      logDebug in interface ResourcepacksPlugin
      Parameters:
      message - The message
      throwable - The throwable
    • getLogLevel

      public Level getLogLevel()
      Description copied from interface: ResourcepacksPlugin
      The debug log level
      Specified by:
      getLogLevel in interface ResourcepacksPlugin
      Returns:
      The debug log level
    • getPlayer

      public ResourcepacksPlayer getPlayer(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Get an online player by its UUID
      Specified by:
      getPlayer in interface ResourcepacksPlugin
      Parameters:
      playerId - The player ID
      Returns:
      The ResourcepacksPlayer
    • getPlayer

      public ResourcepacksPlayer getPlayer(String playerName)
      Description copied from interface: ResourcepacksPlugin
      Get an online player by its name
      Specified by:
      getPlayer in interface ResourcepacksPlugin
      Parameters:
      playerName - The player name
      Returns:
      The ResourcepacksPlayer
    • sendMessage

      public boolean sendMessage(ResourcepacksPlayer player, String key, String... replacements)
      Description copied from interface: ResourcepacksPlugin
      Send a message to a player
      Specified by:
      sendMessage in interface ResourcepacksPlugin
      Parameters:
      player - The player
      key - The key of the message to send
      replacements - An optional array with placeholder replacements
      Returns:
      true if the message was sent; false if the player was offline or the message empty
    • sendMessage

      public boolean sendMessage(ResourcepacksPlayer player, Level level, String key, String... replacements)
      Description copied from interface: ResourcepacksPlugin
      Send a message to a sender
      Specified by:
      sendMessage in interface ResourcepacksPlugin
      Parameters:
      player - The the sender
      level - The level to log to if the sender is the console!
      key - The key of the message to send
      replacements - An optional array with placeholder replacements
      Returns:
      true if the message was sent; false if the player was offline or the message empty
    • log

      public void log(Level level, String message)
      Description copied from interface: ResourcepacksPlugin
      Log a message. This strips out all color codes
      Specified by:
      log in interface ResourcepacksPlugin
      Parameters:
      level - The level at which the message should be logged
      message - The message to log
    • log

      public void log(Level level, String message, Throwable throwable)
      Description copied from interface: ResourcepacksPlugin
      Log a message. This strips out all color codes
      Specified by:
      log in interface ResourcepacksPlugin
      Parameters:
      level - The level at which the message should be logged
      message - The message to log
      throwable - The error to log
    • checkPermission

      public boolean checkPermission(ResourcepacksPlayer player, String perm)
      Description copied from interface: ResourcepacksPlugin
      Check whether or not a player has a permission
      Specified by:
      checkPermission in interface ResourcepacksPlugin
      Parameters:
      player - The player to check
      perm - The permission to check for
      Returns:
      true if the player has the permission; false if not
    • checkPermission

      public boolean checkPermission(UUID playerId, String perm)
      Description copied from interface: ResourcepacksPlugin
      Check whether or not a player has a permission
      Specified by:
      checkPermission in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      perm - The permission to check for
      Returns:
      true if the player has the permission; false if not
    • getPlayerProtocol

      public int getPlayerProtocol(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Get the protocol version of a player
      Specified by:
      getPlayerProtocol in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      Returns:
      The protocol version or -1 if the player isn't online
    • getPlayerClientType

      public ClientType getPlayerClientType(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Get the client type of a player
      Specified by:
      getPlayerClientType in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      Returns:
      The type of the player's client
    • callPackSelectEvent

      public IResourcePackSelectEvent callPackSelectEvent(UUID playerId, ResourcePack pack, IResourcePackSelectEvent.Status status)
      Description copied from interface: ResourcepacksPlugin
      Call the ResourcePackSelectEvent on the corresponding server
      Specified by:
      callPackSelectEvent in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      pack - The ResourcePack that was selected or null if none was selected
      status - The status of the selection
      Returns:
      The ResourcePackSelectEvent interface which might have been modified (especially the pack)
    • callPackSendEvent

      public IResourcePackSendEvent callPackSendEvent(UUID playerId, ResourcePack pack)
      Description copied from interface: ResourcepacksPlugin
      Call the ResourcePackSendEvent on the corresponding server
      Specified by:
      callPackSendEvent in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      pack - The ResourcePack that was send
      Returns:
      The ResourcePackSendEvent interface which might have been modified or cancelled
    • isAuthenticated

      public boolean isAuthenticated(UUID playerId)
      Description copied from interface: ResourcepacksPlugin
      Check whether or not a certain player is currently logged in with auth plugins (currently supports AuthMe Reloaded)
      Specified by:
      isAuthenticated in interface ResourcepacksPlugin
      Parameters:
      playerId - The UUID of the player
      Returns:
      true if he is loggedin; false if not or the status is unknown
    • runTask

      public int runTask(Runnable runnable)
      Description copied from interface: ResourcepacksPlugin
      Run a sync task
      Specified by:
      runTask in interface ResourcepacksPlugin
      Parameters:
      runnable - What to run
      Returns:
      The task id
    • runAsyncTask

      public int runAsyncTask(Runnable runnable)
      Description copied from interface: ResourcepacksPlugin
      Run a task asynchronously
      Specified by:
      runAsyncTask in interface ResourcepacksPlugin
      Parameters:
      runnable - What to run
      Returns:
      The task id
    • setAuthenticated

      public void setAuthenticated(UUID playerId, boolean b)