Class BungeeChatContext
- java.lang.Object
-
- dev.aura.bungeechat.api.placeholder.BungeeChatContext
-
public class BungeeChatContext extends Object
This class represents a context for a message or other chat related action.
It may contain the acting player (sender), the receiver (target), the message and possibly more in the future.
-
-
Field Summary
Fields Modifier and Type Field Description static Predicate<BungeeChatContext>
HAS_CHANNEL
Predefined Predicate to check if a context has a channel.static Predicate<BungeeChatContext>
HAS_MESSAGE
Predefined Predicate to check if a context has a message.static Predicate<BungeeChatContext>
HAS_NO_CHANNEL
Predefined Predicate to check if a context does not have a channel.static Predicate<BungeeChatContext>
HAS_NO_MESSAGE
Predefined Predicate to check if a context does not have a message.static Predicate<BungeeChatContext>
HAS_NO_SENDER
Predefined Predicate to check if a context does not have a sender.static Predicate<BungeeChatContext>
HAS_NO_SERVER
Predefined Predicate to check if a context does not have a server.static Predicate<BungeeChatContext>
HAS_NO_TARGET
Predefined Predicate to check if a context does not have a target.static Predicate<BungeeChatContext>
HAS_SENDER
Predefined Predicate to check if a context has a sender.static Predicate<BungeeChatContext>
HAS_SERVER
Predefined Predicate to check if a context has a server.static Predicate<BungeeChatContext>
HAS_TARGET
Predefined Predicate to check if a context has a target.
-
Constructor Summary
Constructors Constructor Description BungeeChatContext()
BungeeChatContext(BungeeChatAccount sender)
BungeeChatContext(BungeeChatAccount sender, BungeeChatAccount target)
BungeeChatContext(BungeeChatAccount sender, BungeeChatAccount target, String message)
BungeeChatContext(BungeeChatAccount sender, String message)
BungeeChatContext(BungeeChatAccount sender, String message, String server)
BungeeChatContext(String message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canEqual(Object other)
boolean
equals(Object o)
Optional<String>
getChannel()
Optional<String>
getMessage()
Optional<BungeeChatAccount>
getSender()
Optional<String>
getServer()
Optional<BungeeChatAccount>
getTarget()
boolean
hasChannel()
int
hashCode()
boolean
hasMessage()
boolean
hasSender()
boolean
hasServer()
boolean
hasTarget()
void
require(Predicate<? super BungeeChatContext>... requirements)
This method is used to verify if a context is valid.void
setChannel(String channel)
void
setChannel(Optional<String> channel)
void
setMessage(String message)
void
setMessage(Optional<String> message)
void
setSender(BungeeChatAccount sender)
void
setSender(Optional<BungeeChatAccount> sender)
void
setServer(String server)
void
setServer(Optional<String> server)
void
setTarget(BungeeChatAccount target)
void
setTarget(Optional<BungeeChatAccount> target)
String
toString()
-
-
-
Field Detail
-
HAS_SENDER
public static final Predicate<BungeeChatContext> HAS_SENDER
Predefined Predicate to check if a context has a sender.- See Also:
require(Predicate...)
-
HAS_TARGET
public static final Predicate<BungeeChatContext> HAS_TARGET
Predefined Predicate to check if a context has a target.- See Also:
require(Predicate...)
-
HAS_MESSAGE
public static final Predicate<BungeeChatContext> HAS_MESSAGE
Predefined Predicate to check if a context has a message.- See Also:
require(Predicate...)
-
HAS_CHANNEL
public static final Predicate<BungeeChatContext> HAS_CHANNEL
Predefined Predicate to check if a context has a channel.- See Also:
require(Predicate...)
-
HAS_SERVER
public static final Predicate<BungeeChatContext> HAS_SERVER
Predefined Predicate to check if a context has a server.- See Also:
require(Predicate...)
-
HAS_NO_SENDER
public static final Predicate<BungeeChatContext> HAS_NO_SENDER
Predefined Predicate to check if a context does not have a sender.- See Also:
require(Predicate...)
-
HAS_NO_TARGET
public static final Predicate<BungeeChatContext> HAS_NO_TARGET
Predefined Predicate to check if a context does not have a target.- See Also:
require(Predicate...)
-
HAS_NO_MESSAGE
public static final Predicate<BungeeChatContext> HAS_NO_MESSAGE
Predefined Predicate to check if a context does not have a message.- See Also:
require(Predicate...)
-
HAS_NO_CHANNEL
public static final Predicate<BungeeChatContext> HAS_NO_CHANNEL
Predefined Predicate to check if a context does not have a channel.- See Also:
require(Predicate...)
-
HAS_NO_SERVER
public static final Predicate<BungeeChatContext> HAS_NO_SERVER
Predefined Predicate to check if a context does not have a server.- See Also:
require(Predicate...)
-
-
Constructor Detail
-
BungeeChatContext
public BungeeChatContext()
-
BungeeChatContext
public BungeeChatContext(BungeeChatAccount sender)
-
BungeeChatContext
public BungeeChatContext(String message)
-
BungeeChatContext
public BungeeChatContext(BungeeChatAccount sender, String message)
-
BungeeChatContext
public BungeeChatContext(BungeeChatAccount sender, BungeeChatAccount target)
-
BungeeChatContext
public BungeeChatContext(BungeeChatAccount sender, BungeeChatAccount target, String message)
-
BungeeChatContext
public BungeeChatContext(BungeeChatAccount sender, String message, String server)
-
-
Method Detail
-
require
@SafeVarargs public final void require(Predicate<? super BungeeChatContext>... requirements) throws InvalidContextError
This method is used to verify if a context is valid. All passed requirements must be true in order for this test to pass. If it fails anInvalidContextError
is thrown.
It is recommended to use the static predefinedPredicate
s likeHAS_SENDER
.- Parameters:
requirements
- An array of requirements which all must be true for this context to be valid.- Throws:
InvalidContextError
- This assertion error gets thrown when one (or more) requirements are not met. If it is a predefinedPredicate
fromBungeeChatContext
the name will be included in the error message. If not a generic message will be put.- See Also:
HAS_SENDER
,HAS_TARGET
,HAS_MESSAGE
,HAS_CHANNEL
,HAS_NO_SENDER
,HAS_NO_TARGET
,HAS_NO_MESSAGE
,HAS_NO_CHANNEL
-
hasSender
public boolean hasSender()
-
hasTarget
public boolean hasTarget()
-
hasMessage
public boolean hasMessage()
-
hasChannel
public boolean hasChannel()
-
hasServer
public boolean hasServer()
-
setSender
public void setSender(BungeeChatAccount sender)
-
setTarget
public void setTarget(BungeeChatAccount target)
-
setMessage
public void setMessage(String message)
-
setChannel
public void setChannel(String channel)
-
setServer
public void setServer(String server)
-
getSender
public Optional<BungeeChatAccount> getSender()
-
getTarget
public Optional<BungeeChatAccount> getTarget()
-
setSender
public void setSender(Optional<BungeeChatAccount> sender)
-
setTarget
public void setTarget(Optional<BungeeChatAccount> target)
-
canEqual
protected boolean canEqual(Object other)
-
-