-
-
Notifications
You must be signed in to change notification settings - Fork 7
Plugin API
4drian3d edited this page Dec 10, 2021
·
10 revisions
This guide is updated for version 2.0.0 of the plugin, several things have changed that do not work in version 1.x.x.
Currently the plugin has 2 events and methods to handle InfractionPlayers.
@Subscribe
public void onPlayerMessageInfraction(ChatViolationEvent event){
// --------------------- Getters ---------------------
// Get the Infractionplayer that was detected in the detection
InfractionPlayer infractionPlayer = event.getInfractionPlayer();
// Get the type of infraction of the event
InfractionType infractionType = event.getType();
// Get the message that was detected
String message = event.getMessage();
// Get the result of the event, if it is cancelled or allowed
GenericResult result = event.getResult();
// --------------------- Setters ---------------------
// Sets the status of the event. Here you can cancel the event
event.setResult(result);
}
@Subscribe
public void onPlayerCommandInfraction(CommandViolationEvent event){
// --------------------- Getters ---------------------
// Get the Infractionplayer that was detected in the detection
InfractionPlayer infractionPlayer = event.getInfractionPlayer();
// Get the type of infraction of the event
InfractionType infractionType = event.getType();
// Get the command that was detected
String command = event.getCommand();
// Get the result of the event, if it is cancelled or allowed
GenericResult result = event.getResult();
// --------------------- Setters ---------------------
// Sets the status of the event. Here you can cancel the event
event.setResult(result);
}
An InfractionPlayer is an object that stores a player's infringement variables.
Player player = event.getPlayer();
// Based on a Player
InfractionPlayer infractionPlayer = InfractionPlayer.get(player);
//Based on an UUID
InfractionPlayer infractionPlayer = InfractionPlayer.get(player.getUniqueId());
// -------------------- Getters --------------------
// Get the player's name
String name = infractionPlayer.username();
// Obtain the player's online status
// An InfractionPlayer can be online or offline so that you can use its methods at any time.
boolean online = infractionplayer.isOnline()
// Get the message prior to the player's last message
String preLastMessage = infractionPlayer.preLastMessage();
// Get the last message sent by the player
String lastMessage = infractionPlayer.lastMessage();
// Get the command prior to the player's last command
String preLastCommand = infractionPlayer.preLastCommand();
// Get the last command executed by the player
String lastCommand = infractionPlayer.lastCommand();
/**
* Get the time in milliseconds
* when the player was last seen.
* @return time in microseconds of the
* moment when the user exited
*/
long lastTimeSeen = infractionPlayer.getLastSeen();
/**
* Get the time in milliseconds since the last message of the player
* @return time in milliseconds since the last message
*/
long lastTimeSinceMessage = infractionPlayer.getTimeSinceLastMessage();
/**
* Get the time in milliseconds since the last command of the player
* @return time in milliseconds since the last command
*/
long lastTimeSinceCommand = infractionPlayer.getTimeSinceLastCommand();
/**
* Get the violations count of the player
* @return the violations count
* @since 2.0.0
*/
ViolationCount count = infractionPlayer.getViolations();
// -------------------- Setters --------------------
// Set the player's online status
infractionPlayer.isOnline(boolean status);
// Set the player last message
infractionPlayer.lastMessage(String message);
// Set the player last command
infractionPlayer.lastCommand(String message);
ViolationCount count = infractionPlayer.getViolations();
// Adds a violation to the count of a player's infraction.
count.addViolation(InfractionType type);
// Sets the count of any player infringement.
count.setViolations(InfractionType type, int newViolationsCount);
/**
* Reset the count of infraction of any type of this player
* @param types the types
*/
count.resetViolations(InfractionType... types)
/**
* Get the ammount of violations of any type
* @param type the violation type
* @return the count
*/
int violationCount = count.getCount(InfractionType type)