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 Summary
-
Constructor Summary
ConstructorDescriptionVelocityResourcepacks
(com.velocitypowered.api.proxy.ProxyServer proxy, org.slf4j.Logger logger, Path dataFolder) -
Method Summary
Modifier and TypeMethodDescriptioncallPackSelectEvent
(UUID playerId, List<ResourcePack> packs, IResourcePackSelectEvent.Status status) Call the ResourcePackSelectEvent on the corresponding servercallPackSendEvent
(UUID playerId, ResourcePack pack) Call the ResourcePackSendEvent on the corresponding serverboolean
checkPermission
(ResourcepacksPlayer player, String perm) Check whether or not a player has a permissionboolean
checkPermission
(UUID playerId, String perm) Check whether or not a player has a permissionvoid
clearPack
(com.velocitypowered.api.proxy.Player player) void
Clear the packs of a player stored in memory and sends that info to the other servers.net.kyori.adventure.text.Component
getComponents
(ResourcepacksPlayer sender, String key, String... replacements) Get message components from the language configgetConfigMap
(Object configuration) Convert a configuration object to a mapcom.velocitypowered.api.proxy.server.RegisteredServer
getCurrentServer
(com.velocitypowered.api.proxy.Player player) Get the server the player is currently on or connecting toGet the tracker for getting the server a player is on or connecting tocom.velocitypowered.api.plugin.PluginDescription
de.themoep.utils.lang.LangLogger
The debug log levelgetMessage
(ResourcepacksPlayer sender, String key, String... replacements) Get a message from the language configSubChannelHandler<com.velocitypowered.api.proxy.server.RegisteredServer>
Get the handler for sub channels that listens on the "rp:plugin" channel to register new sub channelsgetName()
Get the name of the pluginint
Get the time in which the permanent pack will be reset if the player disconnectsgetPlayer
(com.velocitypowered.api.proxy.Player player) Get an online player by its nameGet an online player by its UUIDgetPlayerClientType
(UUID playerId) Get the client type of a playerint
getPlayerProtocol
(UUID playerId) Get the protocol version of a playercom.velocitypowered.api.proxy.ProxyServer
getProxy()
getStoredPack
(UUID playerId) Get the pack that a certain player has storedGet the version of the pluginboolean
hasBackend
(UUID playerId) Check if a player has a pack set by a backend serverboolean
hasMessage
(ResourcepacksPlayer sender, String key) Check whether or not the language config contains a certain messageboolean
isAuthenticated
(UUID playerId) Check whether or not a certain player is currently logged in with auth plugins (currently supports AuthMe Reloaded)boolean
Get whether the plugin successful enabled or notboolean
Get whether or not the default /usepack behaviour is to apply temporary opr permanentboolean
void
Log a message.void
Log a message.void
Log a debug messagevoid
Log a debug message with a stacktracevoid
onProxyInitialization
(com.velocitypowered.api.event.proxy.ProxyInitializeEvent event) protected void
registerCommand
(PluginCommandExecutor executor) void
reloadConfig
(boolean resend) Reloads the configuration from the file and resends the resource pack to all online playersvoid
removePack
(UUID playerId, ResourcePack pack) Remove a specific pack from a player.void
resendPack
(com.velocitypowered.api.proxy.Player player) Resends the pack that corresponds to the player's servervoid
resendPack
(UUID playerId) Resends the pack that corresponds to the player's serverint
runAsyncTask
(Runnable runnable) Run a task asynchronouslyint
Run a sync taskvoid
Save changes made on runtime to the configboolean
sendMessage
(ResourcepacksPlayer player, String key, String... replacements) Send a message to a playerboolean
sendMessage
(ResourcepacksPlayer player, Level level, String key, String... replacements) Send a message to a senderprotected void
sendPack
(com.velocitypowered.api.proxy.Player player, ResourcePack pack) Send a resourcepack to a connected playervoid
sendPack
(UUID playerId, ResourcePack pack) Internal method to send a resoucepack to a player, please usePackManager.setPack(UUID, ResourcePack)
!void
sendPackInfo
(UUID playerId) Send a plugin message to the server/proxy the player is connected to!void
setAuthenticated
(UUID playerId, boolean b) void
setBackend
(UUID playerId) Add a player's UUID to the list of players with a backend packvoid
setStoredPack
(UUID playerId, String packName) 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 resetvoid
unsetBackend
(UUID playerId) Remove a player's UUID from the list of players with a backend packMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.themoep.utils.lang.velocity.Languaged
getResourceAsStream
Methods inherited from interface de.themoep.resourcepacksplugin.core.ResourcepacksPlugin
getMessage, getMessage, getPlayerPackFormat, startupMessage, supportsMultiplePacks
-
Field Details
-
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
-
loadConfig
public boolean loadConfig()- Specified by:
loadConfig
in interfaceResourcepacksPlugin
-
getConfigMap
Description copied from interface:ResourcepacksPlugin
Convert a configuration object to a map- Specified by:
getConfigMap
in interfaceResourcepacksPlugin
- 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 interfaceResourcepacksPlugin
- 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 interfaceResourcepacksPlugin
-
setStoredPack
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 interfaceResourcepacksPlugin
- Parameters:
playerId
- UUID of the playerpackName
- Name of the pack
-
getStoredPack
Description copied from interface:ResourcepacksPlugin
Get the pack that a certain player has stored- Specified by:
getStoredPack
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player- Returns:
- The name of the pack or
null
if none was stored
-
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 interfaceResourcepacksPlugin
- 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 interfaceResourcepacksPlugin
- Returns:
- The time in seconds; 0 or below should disable that
-
getConfig
-
isEnabled
public boolean isEnabled()Get whether the plugin successful enabled or not- Specified by:
isEnabled
in interfaceResourcepacksPlugin
- 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
Description copied from interface:ResourcepacksPlugin
Resends the pack that corresponds to the player's server- Specified by:
resendPack
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player to resend the pack for
-
sendPack
Send a resourcepack to a connected player- Parameters:
player
- The Player to send the pack topack
- The resourcepack to send the pack to
-
sendPackInfo
Description copied from interface:ResourcepacksPlugin
Send a plugin message to the server/proxy the player is connected to!
- Specified by:
sendPackInfo
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player to send the pack info for
-
getCurrentServer
public com.velocitypowered.api.proxy.server.RegisteredServer getCurrentServer(com.velocitypowered.api.proxy.Player player) Get the server the player is currently on or connecting to- Parameters:
player
- The player- Returns:
- The name of the server
-
sendPack
Description copied from interface:ResourcepacksPlugin
Internal method to send a resoucepack to a player, please usePackManager.setPack(UUID, ResourcePack)
!- Specified by:
sendPack
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player to send the pack topack
- The resourcepack to send to a player
-
removePack
Description copied from interface:ResourcepacksPlugin
Remove a specific pack from a player. Only works on 1.20.3+- Specified by:
removePack
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player to remove the pack frompack
- The pack to remove
-
clearPack
public void clearPack(com.velocitypowered.api.proxy.Player player) -
clearPack
Description copied from interface:ResourcepacksPlugin
Clear the packs of a player stored in memory and sends that info to the other servers.
Does not remove from the client!- Specified by:
clearPack
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player to clear the packs for.
-
getPackManager
- Specified by:
getPackManager
in interfaceResourcepacksPlugin
-
getUserManager
- Specified by:
getUserManager
in interfaceResourcepacksPlugin
-
setBackend
Add a player's UUID to the list of players with a backend pack- Parameters:
playerId
- The uuid of the player
-
unsetBackend
Remove a player's UUID from the list of players with a backend pack- Parameters:
playerId
- The uuid of the player
-
hasBackend
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
Description copied from interface:ResourcepacksPlugin
Get a message from the language config- Specified by:
getMessage
in interfaceResourcepacksPlugin
- Parameters:
sender
- The sender to get the message from, will use the client language if availablekey
- The message keyreplacements
- 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 availablekey
- The message keyreplacements
- Optional placeholder replacement array- Returns:
- The components or an error message if not available, never null
-
hasMessage
Description copied from interface:ResourcepacksPlugin
Check whether or not the language config contains a certain message- Specified by:
hasMessage
in interfaceResourcepacksPlugin
- Parameters:
sender
- The senderkey
- The message key- Returns:
true
if the config contains the message;false
if not
-
getName
Description copied from interface:ResourcepacksPlugin
Get the name of the plugin- Specified by:
getName
in interfacede.themoep.utils.lang.velocity.Languaged
- Specified by:
getName
in interfaceResourcepacksPlugin
- Returns:
- The plugin's name as a string
-
getVersion
Description copied from interface:ResourcepacksPlugin
Get the version of the plugin- Specified by:
getVersion
in interfaceResourcepacksPlugin
- Returns:
- The plugin's version as a string
-
getProxy
public com.velocitypowered.api.proxy.ProxyServer getProxy() -
getPluginLogger
- Specified by:
getPluginLogger
in interfaceResourcepacksPlugin
-
getLangLogger
public de.themoep.utils.lang.LangLogger getLangLogger()- Specified by:
getLangLogger
in interfacede.themoep.utils.lang.velocity.Languaged
-
getDataFolder
- Specified by:
getDataFolder
in interfacede.themoep.utils.lang.velocity.Languaged
- Specified by:
getDataFolder
in interfaceResourcepacksPlugin
-
getDescription
public com.velocitypowered.api.plugin.PluginDescription getDescription() -
logDebug
Description copied from interface:ResourcepacksPlugin
Log a debug message- Specified by:
logDebug
in interfaceResourcepacksPlugin
- Parameters:
message
- The message
-
logDebug
Description copied from interface:ResourcepacksPlugin
Log a debug message with a stacktrace- Specified by:
logDebug
in interfaceResourcepacksPlugin
- Parameters:
message
- The messagethrowable
- The throwable
-
getLogLevel
Description copied from interface:ResourcepacksPlugin
The debug log level- Specified by:
getLogLevel
in interfaceResourcepacksPlugin
- Returns:
- The debug log level
-
getPlayer
Description copied from interface:ResourcepacksPlugin
Get an online player by its UUID- Specified by:
getPlayer
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The player ID- Returns:
- The ResourcepacksPlayer
-
getPlayer
Description copied from interface:ResourcepacksPlugin
Get an online player by its name- Specified by:
getPlayer
in interfaceResourcepacksPlugin
- Parameters:
playerName
- The player name- Returns:
- The ResourcepacksPlayer
-
getPlayer
-
sendMessage
Description copied from interface:ResourcepacksPlugin
Send a message to a player- Specified by:
sendMessage
in interfaceResourcepacksPlugin
- Parameters:
player
- The playerkey
- The key of the message to sendreplacements
- 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 interfaceResourcepacksPlugin
- Parameters:
player
- The the senderlevel
- The level to log to if the sender is the console!key
- The key of the message to sendreplacements
- An optional array with placeholder replacements- Returns:
true
if the message was sent;false
if the player was offline or the message empty
-
log
Description copied from interface:ResourcepacksPlugin
Log a message. This strips out all color codes- Specified by:
log
in interfaceResourcepacksPlugin
- Parameters:
level
- The level at which the message should be loggedmessage
- The message to log
-
log
Description copied from interface:ResourcepacksPlugin
Log a message. This strips out all color codes- Specified by:
log
in interfaceResourcepacksPlugin
- Parameters:
level
- The level at which the message should be loggedmessage
- The message to logthrowable
- The error to log
-
checkPermission
Description copied from interface:ResourcepacksPlugin
Check whether or not a player has a permission- Specified by:
checkPermission
in interfaceResourcepacksPlugin
- Parameters:
player
- The player to checkperm
- The permission to check for- Returns:
true
if the player has the permission;false
if not
-
checkPermission
Description copied from interface:ResourcepacksPlugin
Check whether or not a player has a permission- Specified by:
checkPermission
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the playerperm
- The permission to check for- Returns:
true
if the player has the permission;false
if not
-
getPlayerProtocol
Description copied from interface:ResourcepacksPlugin
Get the protocol version of a player- Specified by:
getPlayerProtocol
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player- Returns:
- The protocol version or -1 if the player isn't online
-
getPlayerClientType
Description copied from interface:ResourcepacksPlugin
Get the client type of a player- Specified by:
getPlayerClientType
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player- Returns:
- The type of the player's client
-
callPackSelectEvent
public IResourcePackSelectEvent callPackSelectEvent(UUID playerId, List<ResourcePack> packs, IResourcePackSelectEvent.Status status) Description copied from interface:ResourcepacksPlugin
Call the ResourcePackSelectEvent on the corresponding server- Specified by:
callPackSelectEvent
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the playerpacks
- The ResourcePacks that were selected or an empty list if none were selectedstatus
- The status of the selection- Returns:
- The ResourcePackSelectEvent interface which might have been modified (especially the pack)
-
callPackSendEvent
Description copied from interface:ResourcepacksPlugin
Call the ResourcePackSendEvent on the corresponding server- Specified by:
callPackSendEvent
in interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the playerpack
- The ResourcePack that was send- Returns:
- The ResourcePackSendEvent interface which might have been modified or cancelled
-
isAuthenticated
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 interfaceResourcepacksPlugin
- Parameters:
playerId
- The UUID of the player- Returns:
true
if he is loggedin;false
if not or the status is unknown
-
runTask
Description copied from interface:ResourcepacksPlugin
Run a sync task- Specified by:
runTask
in interfaceResourcepacksPlugin
- Parameters:
runnable
- What to run- Returns:
- The task id
-
runAsyncTask
Description copied from interface:ResourcepacksPlugin
Run a task asynchronously- Specified by:
runAsyncTask
in interfaceResourcepacksPlugin
- Parameters:
runnable
- What to run- Returns:
- The task id
-
setAuthenticated
-
getMessageChannelHandler
public SubChannelHandler<com.velocitypowered.api.proxy.server.RegisteredServer> getMessageChannelHandler()Get the handler for sub channels that listens on the "rp:plugin" channel to register new sub channels- Returns:
- The message channel handler
-
getCurrentServerTracker
Get the tracker for getting the server a player is on or connecting to- Returns:
- The tracker
-