-
Notifications
You must be signed in to change notification settings - Fork 19
Dev API
This is the documentation of ChatEx's API. You can include the api as followed:
<repositories>
...
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
...
<dependency>
<groupId>com.github.TheJeterLP</groupId>
<artifactId>ChatEx</artifactId>
<version>Version</version>
</dependency>
</dependencies>
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.TheJeterLP:ChatEx:Version'
}
Be carefull to include the correct version for your project. To include the ChatEx API in other waysread this site: Jitpack - ChatEx.
ChatEx includes the following events which you can handle as normal bukkit events:
This event gets fired if a player uses the rangemode.
@EventHandler
public void onEvent(PlayerUsesRangeModeEvent event){
event.getPlayer(); //returns the player which fired the event
event.getMessage(); //returns the message which the player wrote
event.setMessage(String message); //set the message the player will send
}
If this event is cancelled the message will not be sent.
This event gets fired if a player uses the global-chat.
@EventHandler
public void onEvent(PlayerUsesGlobalChatEvent event){
event.getPlayer(); //returns the player which fired the event
event.getMessage(); //returns the message which the player wrote
event.setMessage(String message); //set the message the player will send
}
This event gets fired if a player writes a word from the BlockedWords
section in the config.yml
@EventHandler
public void onEvent(MessageContainsBlockedWordEvent event){
event.getPlayer(); //returns the player which fired the event
event.getMessage(); //returns the message which the player wrote
event.getPluginMessage(); //returns the message the plugin will send the player
event.setMessage(String message); //set the message the player will send
event.setPluginMessage(String pluginMessage) //Set the message the message which the plugin will send to the player
}
This event gets fired if a players message gets blocked by the AdManager
@EventHandler
public void onEvent(MessageBlockedByAdManagerEvent event){
event.getPlayer(); //returns the player which fired the event
event.getMessage(); //returns the message which the player wrote
event.getPluginMessage(); //returns the message the plugin will send the player
event.setMessage(String message); //set the message the player will send
event.setPluginMessage(String pluginMessage) //Set the message the message which the plugin will send to the player
}
This event gets fired if a players message gets blocked by the SpamManager
@EventHandler
public void onEvent(MessageBlockedBySpamManagerEventevent){
event.getPlayer(); //returns the player which fired the event
event.getMessage(); //returns the message which the player wrote
event.getPluginMessage(); //returns the message the plugin will send the player
event.getRemainingTime(); //returns the remaining time (In Seconds) the player cant write
event.setMessage(String message); //set the message the player will send
event.setPluginMessage(String pluginMessage) //Set the message the message which the plugin will send to the player
}
The ChatExAPIclass contains many usefull informations of player. You can get it with:
ChatExAPI chatExAPI = new ChatExAPI();
String permissionHandlerName = chatExAPI.getPermissionHandlerName();
AntiSpamManager antiSpamManager = chatExAPI.getAntiSpamManager();
String prefix = chatExAPI.getPrefix(Player p);
String Suffix = chatExAPI.getSuffix(Player p);
String[] groupNames = chatExAPI.getGroupNames(Player p);
String messageFormat = chatExAPI.getMessageFormat(Player p);
String globalMessageFormat = chatExAPI.getGlobalMessageFormat(Player p);
The AntiSpamManager contains information about the players cooldown. You can get it with:
AntiSpamManager antiSpamManager = chatExAPI.getAntiSpamManager();
You can get a players remaining mute time with:
long timeInSeconds = antiSpamManager.getRemainingSeconds(Player player); //returns the remaining cooldown in seconds
long timeInMillis = antiSpamManager.getRemainingMillis(Player player); //return the remaining cooldown in milliseconds