public interface NucleusPrivateMessagingService
Modifier and Type | Method and Description |
---|---|
boolean |
canSpyOn(User spyingUser,
CommandSource... sourcesToSpyOn)
Returns whether the specified user can spy on all of the specified sources.
|
boolean |
canSpySameLevel()
If using social spy levels, this returns whether those on the same social spy level as the participants of a message can read a message.
|
<T extends CommandSource & Identifiable> |
clearCommandSourceReplyTo(T user)
|
void |
clearConsoleReplyTo()
Removes the
CommandSource that the console will reply to if /r is used. |
void |
clearReplyTo(User user)
|
Tristate |
forcedSocialSpyState(User user)
Returns whether the specified user can toggle social spy
Tristate.UNDEFINED , or whether they are forced to use social spy Tristate.TRUE , or do not have permission to do so Tristate.FALSE . |
<T extends CommandSource & Identifiable> |
getCommandSourceReplyTo(T from)
|
Optional<CommandSource> |
getConsoleReplyTo()
Gets the
CommandSource that the console will reply to if /r is used, if any. |
int |
getCustomTargetLevel()
Gets the social spy level for any message targets registered using
registerMessageTarget(UUID, String, Text, Supplier) . |
Optional<CommandSource> |
getReplyTo(User from)
|
int |
getServerLevel()
Gets the social spy level the server is assigned.
|
int |
getSocialSpyLevel(User user)
Gets the social spy level the user is assigned.
|
boolean |
isSocialSpy(User user)
Returns whether the user is able to see all private messages sent on the server.
|
boolean |
isUsingSocialSpyLevels()
Returns whether the server is using social spy levels.
|
Set<CommandSource> |
onlinePlayersCanSpyOn(boolean includeConsole,
CommandSource... sourcesToSpyOn)
Returns the
CommandSource s that are online and can spy on all of the specified sources. |
<T extends CommandSource & Identifiable> |
registerMessageTarget(UUID uniqueId,
String targetName,
Text displayName,
Supplier<T> target)
Registers a message target.
|
boolean |
sendMessage(CommandSource sender,
CommandSource receiver,
String message)
Sends a message as the sender to the receiver.
|
<T extends CommandSource & Identifiable> |
setCommandSourceReplyTo(T source,
CommandSource replyTo)
|
void |
setConsoleReplyTo(CommandSource toReplyTo)
Sets the
CommandSource that the console will reply to if /r is used. |
void |
setReplyTo(User user,
CommandSource toReplyTo)
|
boolean |
setSocialSpy(User user,
boolean isSocialSpy)
Sets whether the user is able to see all private messages on the server.
|
boolean isSocialSpy(User user)
user
- The User
to check.true
if the user has Social Spy enabled.boolean isUsingSocialSpyLevels()
true
if so.boolean canSpySameLevel()
In the following scenarios, Alice has a social spy level of 5, and Bob a social spy level of 10.
If this method returns true
, and Alice sends a message to Bob, Eve must have a level of 10 or above, to see the message. If
Eve has a level of 9 or below, then because Bob's level is higher than hers, she cannot see the message.
If this method returns false
, and Alice sends a message to Bob, Eve must have a level of 11 or above, to see
the message. If Eve has a level of 10 or below, then because Bob's level is the same than hers, she cannot see
the message.
int getCustomTargetLevel()
registerMessageTarget(UUID, String, Text, Supplier)
.int getServerLevel()
Integer.MAX_VALUE
, or zero if levels aren't
enabled.int getSocialSpyLevel(User user)
user
- The user to check.Tristate forcedSocialSpyState(User user)
Tristate.UNDEFINED
, or whether they are forced to use social spy Tristate.TRUE
, or do not have permission to do so Tristate.FALSE
.user
- The use to check.Tristate
that indicates what state the user might be forced into.boolean setSocialSpy(User user, boolean isSocialSpy)
user
- The User
isSocialSpy
- true
to turn Social Spy on, false
otherwise.true
if the change was fulfilled, false
if the user does not have permissionboolean canSpyOn(User spyingUser, CommandSource... sourcesToSpyOn) throws IllegalArgumentException
This will return false
if the spying user is also in the list of users to spy on.
spyingUser
- The user that will be spying.sourcesToSpyOn
- The CommandSource
s to spy upon.true
if the user can spy on all the users.IllegalArgumentException
- thrown if no CommandSource
s are supplied.Set<CommandSource> onlinePlayersCanSpyOn(boolean includeConsole, CommandSource... sourcesToSpyOn) throws IllegalArgumentException
CommandSource
s that are online and can spy on all of the specified sources.
This will not return players in the list of users to spy on.
includeConsole
- Whether to include the console in the returned Set
.sourcesToSpyOn
- The CommandSource
s to spy upon.Set
of CommandSource
s that can spy upon the specified users.IllegalArgumentException
- thrown if no CommandSource
s are supplied.boolean sendMessage(CommandSource sender, CommandSource receiver, String message)
sender
- The sender.receiver
- The reciever.message
- The message to send.true
if the message was sent, false
otherwise.Optional<CommandSource> getConsoleReplyTo()
CommandSource
that the console will reply to if /r
is used, if any.CommandSource
.Optional<CommandSource> getReplyTo(User from)
from
- The User
to inspect.CommandSource
.<T extends CommandSource & Identifiable> Optional<CommandSource> getCommandSourceReplyTo(T from)
T
- The Identifiable
CommandSource
type.from
- The T
to inspect.CommandSource
.void setReplyTo(User user, CommandSource toReplyTo)
user
- The User
to modify.toReplyTo
- The CommandSource
.void setConsoleReplyTo(CommandSource toReplyTo)
CommandSource
that the console will reply to if /r
is used.toReplyTo
- The CommandSource
.<T extends CommandSource & Identifiable> void setCommandSourceReplyTo(T source, CommandSource replyTo)
CommandSource
that the specified CommandSource
will reply to if /r
is used.
If the CommandSource
in both cases isn't a normal target or isn't registered, this will fail silently.
T
- The Identifiable
CommandSource
type.source
- The T
to modify.replyTo
- The CommandSource
to now reply to.<T extends CommandSource & Identifiable> void clearCommandSourceReplyTo(T user)
T
- The Identifiable
CommandSource
type.user
- The User
to modify.void clearConsoleReplyTo()
CommandSource
that the console will reply to if /r
is used.<T extends CommandSource & Identifiable> void registerMessageTarget(UUID uniqueId, String targetName, @Nullable Text displayName, Supplier<T> target) throws NullPointerException, IllegalArgumentException, IllegalStateException
A message target is, perhaps unsurprisingly, a valid target for messaging. Players can message this target using
/m <targetName> [message]
Message targets cannot be ignored. They are mostly intended for bot use.
T
- The type that implements both CommandSource
and Identifiable
.uniqueId
- The UUID
of the target.targetName
- The name of the target in commands.displayName
- The display name of the target. If null
, CommandSource.getName()
is used.target
- A Supplier
of the message target, which must implement both CommandSource
and Identifiable
.NullPointerException
- thrown if any non Nullable
parameter is null.IllegalArgumentException
- thrown if the UUID
is the zero UUID.IllegalStateException
- thrown if the UUID
has already been registered.