xWhitelist API 📋
📄 Introduction
The xWhitelistAPI provides static methods to interact programmatically with xWhitelist. You can manage the whitelist, maintenance whitelist, and check plugin status directly from your code without creating an instance.
🛠 Installation
First of all, add the repository and dependency of xWhitelist.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.xDrygo</groupId>
<artifactId>xWhitelist</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>After adding the dependency, add xWhitelist as dependency in your plugin.
name: MyPlugin
main: com.example.MyPlugin.MyPlugin
version: 1.0
depend: # depend if is necesary the API, soft-depend if is opcional use.
- xWhitelist📋 xWhitelistAPI Methods
📝 General Whitelist Methods
Click to expand
Returns whether the main whitelist is enabled.boolean isWhitelistActive()
if (XWhitelistAPI.isWhitelistActive()) {
Bukkit.getLogger().info("Whitelist is enabled!");
}
Toggles the main whitelist status (enabled/disabled).void toggleWhitelist()
XWhitelistAPI.toggleWhitelist(); // Switches whitelist on/off
Returns a list of players currently in the local file whitelist.List<String> getFileWhitelist()
public void printFileWhitelist() {
List<String> players = XWhitelistAPI.getFileWhitelist();
players.forEach(player -> Bukkit.getLogger().info(player));
}
Checks if a player is in the whitelist (works for both file and MySQL modes).boolean isPlayerInWhitelist(String playerName)
if (XWhitelistAPI.isPlayerInWhitelist("Steve")) {
Bukkit.getLogger().info("Steve is whitelisted!");
}
Adds a player to the whitelist (file or MySQL).void addPlayerToWhitelist(String playerName)
XWhitelistAPI.addPlayerToWhitelist("Alex");
Removes a player from the whitelist (file or MySQL).void removePlayerFromWhitelist(String playerName)
XWhitelistAPI.removePlayerFromWhitelist("Alex");
Returns a list of all whitelisted players.List<String> listWhitelist()
public void printWhitelist() {
List<String> allPlayers = XWhitelistAPI.listWhitelist();
allPlayers.forEach(player -> Bukkit.getLogger().info(player));
}
Clears all entries in the whitelist.void clearWhitelist()
XWhitelistAPI.clearWhitelist();🛠️ Maintenance Whitelist Methods
Click to expand
Returns whether the maintenance whitelist is enabled.boolean isMaintenanceWhitelistActive()
if (XWhitelistAPI.isMaintenanceWhitelistActive()) {
Bukkit.getLogger().info("Maintenance whitelist is active!");
}
Toggles the maintenance whitelist status.void toggleMaintenanceWhitelist()
XWhitelistAPI.toggleMaintenanceWhitelist();
Returns the list of players in the maintenance whitelist.List<String> getMaintenanceWhitelist()
public void printMaintenanceWhitelist() {
List<String> staff = XWhitelistAPI.getMaintenanceWhitelist();
staff.forEach(player -> Bukkit.getLogger().info(player));
}
Checks if a player is in the maintenance whitelist.boolean isPlayerInMaintenanceWhitelist(String playerName)
if (XWhitelistAPI.isPlayerInMaintenanceWhitelist("Steve")) {
Bukkit.getLogger().info("Steve is in the maintenance whitelist!");
}
Adds a player to the maintenance whitelist.void addPlayerToMaintenanceWhitelist(String playerName)
XWhitelistAPI.addPlayerToMaintenanceWhitelist("Alex");
Removes a player from the maintenance whitelist.void removePlayerFromMaintenanceWhitelist(String playerName)
XWhitelistAPI.removePlayerFromMaintenanceWhitelist("Alex");
Clears all entries in the maintenance whitelist.void cleanupMaintenanceWhitelist()
XWhitelistAPI.cleanupMaintenanceWhitelist();
Returns a list of all players in the maintenance whitelist.List<String> listMaintenanceWhitelist()
public void printMaintenanceWhitelist() {
List<String> staffList = XWhitelistAPI.listMaintenanceWhitelist();
staffList.forEach(player -> Bukkit.getLogger().info(player));
}💡 Notes
- All API methods are static, so you do not need to instantiate
XWhitelistAPI. - Methods handle both local file and MySQL storage automatically.
- Maintenance whitelist methods always operate on the staff whitelist file, even if MySQL is enabled.
- Be sure to reload your configuration after modifying whitelist files if needed.