Class VeinMinerPlayer
- All Implemented Interfaces:
MessageReceiver
,PluginMessageListener
,ServerboundPluginMessageListener
-
Constructor Summary
ConstructorDescriptionVeinMinerPlayer
(@NotNull PlatformPlayer player, @NotNull ClientConfig clientConfig) Construct a newVeinMinerPlayer
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
executeWhenClientIsReady
(@NotNull Runnable runnable) Execute the givenRunnable
when the client is ready.boolean
executeWhenClientIsReady
(@NotNull Consumer<VeinMinerPlayer> consumer) Execute the givenConsumer
when the client is ready.@NotNull ActivationStrategy
Get theActivationStrategy
to use for this player.@NotNull ClientConfig
Get theClientConfig
for this player.@NotNull @UnmodifiableView Set<VeinMinerToolCategory>
Get this player's disabledVeinMinerToolCategories
.@NotNull PlatformPlayer
Get thePlatformPlayer
wrapped by this vein miner player.@NotNull UUID
Get theUUID
of this player.@NotNull VeinMiningPattern
Get theVeinMiningPattern
to use for this player.void
handleHandshake
(@NotNull PluginMessageServerboundHandshake message) Handles thePluginMessageServerboundHandshake
message.void
handleRequestVeinMine
(@NotNull PluginMessageServerboundRequestVeinMine message) Handles thePluginMessageServerboundRequestVeinMine
message.void
handleSelectPattern
(@NotNull PluginMessageServerboundSelectPattern message) Handles thePluginMessageServerboundSelectPattern
message.void
handleToggleVeinMiner
(@NotNull PluginMessageServerboundToggleVeinMiner message) Handles thePluginMessageServerboundToggleVeinMiner
message.boolean
Check whether or not vein miner is active as a result of this user's client mod.boolean
Check whether or not the client is ready to receive messages.boolean
isDirty()
Check whether or not this player data has been modified since last write.boolean
Check whether or not this player is using the client mod.boolean
Check whether or not vein miner is currently active and ready to be used.boolean
Check whether or not vein miner is completely disabled.boolean
Check whether or not vein miner is completely enabled.boolean
isVeinMinerEnabled
(@NotNull VeinMinerToolCategory category) Check whether or not the givenVeinMinerToolCategory
is enabled.boolean
Check whether or not vein miner has been partially disabled but still has at least one category still enabled.boolean
Check whether or not the player is actively vein mining.void
sendMessage
(@NotNull NamespacedKey channel, byte[] message) Send a message represented by the given bytes on the specified channel.void
setActivationStrategy
(@NotNull ActivationStrategy activationStrategy) Set theActivationStrategy
to use for this player.void
setClientConfig
(@NotNull ClientConfig clientConfig) Set theClientConfig
for this player.void
setDirty
(boolean dirty) Set whether or not this player data should be written.boolean
setVeinMinerEnabled
(boolean enabled) Set whether or not vein miner is enabled entirely.boolean
setVeinMinerEnabled
(@NotNull VeinMinerToolCategory category, boolean enabled) Set whether or not the givenVeinMinerToolCategory
is enabled.void
setVeinMining
(boolean veinMining) Set whether or not the player is actively vein mining.void
setVeinMiningPattern
(@NotNull VeinMiningPattern veinMiningPattern) Set theVeinMiningPattern
to use for this player and update the client.void
setVeinMiningPattern
(@NotNull VeinMiningPattern veinMiningPattern, boolean updateClient) Set theVeinMiningPattern
to use for this player.
-
Constructor Details
-
VeinMinerPlayer
@Internal public VeinMinerPlayer(@NotNull @NotNull PlatformPlayer player, @NotNull @NotNull ClientConfig clientConfig) Construct a newVeinMinerPlayer
.This is an internal method. To get an instance of VeinMinerPlayer, the
VeinMinerPlayerManager
should be used instead. Constructing a new instance of this class may have unintended side-effects and will not have accurate information tracked by VeinMiner.- Parameters:
player
- the playerclientConfig
- the client configuration- See Also:
-
-
Method Details
-
getPlayer
Get thePlatformPlayer
wrapped by this vein miner player.- Returns:
- the platform player
-
getPlayerUUID
Get theUUID
of this player.- Returns:
- the player UUID
-
setVeinMinerEnabled
public boolean setVeinMinerEnabled(@NotNull @NotNull VeinMinerToolCategory category, boolean enabled) Set whether or not the givenVeinMinerToolCategory
is enabled.- Parameters:
category
- the category to changeenabled
- whether or not the category is enabled- Returns:
- true if the category state was changed, false if the category remains unchanged
-
setVeinMinerEnabled
public boolean setVeinMinerEnabled(boolean enabled) Set whether or not vein miner is enabled entirely.If
true
and one or more categories are disabled, it will enable all disabled categories. If {code false} not all categories have been disabled, it will disable all remaining categories.- Parameters:
enabled
- whether or not to enable vein miner- Returns:
- true if at least one category was changed as a result of the enable toggle
-
isVeinMinerEnabled
Check whether or not the givenVeinMinerToolCategory
is enabled.- Parameters:
category
- the category to check- Returns:
- true if enabled, false otherwise
-
isVeinMinerEnabled
public boolean isVeinMinerEnabled()Check whether or not vein miner is completely enabled.If at least one category is disabled (according to
isVeinMinerEnabled(VeinMinerToolCategory)
), this method will returnfalse
.- Returns:
- true if fully enabled, false if at least one category is disabled
-
isVeinMinerDisabled
public boolean isVeinMinerDisabled()Check whether or not vein miner is completely disabled.If at least one category is enabled (according to
isVeinMinerEnabled(VeinMinerToolCategory)
), this method will returnfalse
.- Returns:
- true if fully disabled, false if at least one category is enabled
-
isVeinMinerPartiallyDisabled
public boolean isVeinMinerPartiallyDisabled()Check whether or not vein miner has been partially disabled but still has at least one category still enabled.- Returns:
- true if partially disabled, false if all categories are enabled or all categories are disabled
-
getDisabledCategories
Get this player's disabledVeinMinerToolCategories
.- Returns:
- the disabled tool categories
-
setActivationStrategy
Set theActivationStrategy
to use for this player.- Parameters:
activationStrategy
- the activation strategy
-
getActivationStrategy
Get theActivationStrategy
to use for this player.- Returns:
- the activation strategy
-
setVeinMiningPattern
public void setVeinMiningPattern(@NotNull @NotNull VeinMiningPattern veinMiningPattern, boolean updateClient) Set theVeinMiningPattern
to use for this player.- Parameters:
veinMiningPattern
- the patternupdateClient
- whether or not the client should be informed of this update
-
setVeinMiningPattern
Set theVeinMiningPattern
to use for this player and update the client.- Parameters:
veinMiningPattern
- the pattern
-
getVeinMiningPattern
Get theVeinMiningPattern
to use for this player.- Returns:
- the pattern
-
executeWhenClientIsReady
Execute the givenRunnable
when the client is ready.- Parameters:
runnable
- the runnable to execute- Returns:
- true if the client is not yet ready and the task was queued, false if the task was executed immediately
- See Also:
-
executeWhenClientIsReady
Execute the givenConsumer
when the client is ready.- Parameters:
consumer
- the consumer to execute- Returns:
- true if the client is not yet ready and the task was queued, false if the task was executed immediately
- See Also:
-
isClientReady
public boolean isClientReady()Check whether or not the client is ready to receive messages.This method will only be true if
isUsingClientMod()
is true, and if the client has successfully shaken hands with the server, is capable of being sent a client message, and has been synchronized with the server as per the protocol specification.- Returns:
- true if the client is ready, false otherwise
- See Also:
-
isUsingClientMod
public boolean isUsingClientMod()Check whether or not this player is using the client mod.- Returns:
- true if using client mod, false otherwise
-
isClientKeyPressed
public boolean isClientKeyPressed()Check whether or not vein miner is active as a result of this user's client mod.- Returns:
- true if active, false otherwise
-
setClientConfig
Set theClientConfig
for this player.- Parameters:
clientConfig
- the client config to set
-
getClientConfig
Get theClientConfig
for this player.Note that this configuration only really applies if
isUsingClientMod()
is true.- Returns:
- the client config
-
isVeinMinerActive
public boolean isVeinMinerActive()Check whether or not vein miner is currently active and ready to be used.NOTE: Do not confuse this with
isVeinMinerEnabled()
. This method verifies whether or not the player has activated vein miner according to their current activation strategy (getActivationStrategy()
), NOT whether they have it enabled via commands.- Returns:
- true if active, false otherwise
-
setVeinMining
@Internal public void setVeinMining(boolean veinMining) Set whether or not the player is actively vein mining.Not part of the public API. This method is intended for internal use only.
- Parameters:
veinMining
- the new vein mining state
-
isVeinMining
public boolean isVeinMining()Check whether or not the player is actively vein mining.- Returns:
- true if using vein miner, false otherwise
-
setDirty
public void setDirty(boolean dirty) Set whether or not this player data should be written.- Parameters:
dirty
- true if dirty, false otherwise
-
isDirty
public boolean isDirty()Check whether or not this player data has been modified since last write.- Returns:
- true if modified, false otherwise
-
sendMessage
Description copied from interface:MessageReceiver
Send a message represented by the given bytes on the specified channel.- Specified by:
sendMessage
in interfaceMessageReceiver
- Parameters:
channel
- the channel on which the message should be sentmessage
- the message bytes to be sent
-
handleHandshake
Description copied from interface:ServerboundPluginMessageListener
Handles thePluginMessageServerboundHandshake
message.- Specified by:
handleHandshake
in interfaceServerboundPluginMessageListener
- Parameters:
message
- the message
-
handleToggleVeinMiner
@Internal public void handleToggleVeinMiner(@NotNull @NotNull PluginMessageServerboundToggleVeinMiner message) Description copied from interface:ServerboundPluginMessageListener
Handles thePluginMessageServerboundToggleVeinMiner
message.- Specified by:
handleToggleVeinMiner
in interfaceServerboundPluginMessageListener
- Parameters:
message
- the message
-
handleRequestVeinMine
@Internal public void handleRequestVeinMine(@NotNull @NotNull PluginMessageServerboundRequestVeinMine message) Description copied from interface:ServerboundPluginMessageListener
Handles thePluginMessageServerboundRequestVeinMine
message.- Specified by:
handleRequestVeinMine
in interfaceServerboundPluginMessageListener
- Parameters:
message
- the message
-
handleSelectPattern
@Internal public void handleSelectPattern(@NotNull @NotNull PluginMessageServerboundSelectPattern message) Description copied from interface:ServerboundPluginMessageListener
Handles thePluginMessageServerboundSelectPattern
message.- Specified by:
handleSelectPattern
in interfaceServerboundPluginMessageListener
- Parameters:
message
- the message
-