πŸ’»xWhitelist API

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
  • boolean isWhitelistActive() Returns whether the main whitelist is enabled.

if (XWhitelistAPI.isWhitelistActive()) {
    Bukkit.getLogger().info("Whitelist is enabled!");
}
  • void toggleWhitelist() Toggles the main whitelist status (enabled/disabled).

XWhitelistAPI.toggleWhitelist(); // Switches whitelist on/off
  • List<String> getFileWhitelist() Returns a list of players currently in the local file whitelist.

public void printFileWhitelist() {
    List<String> players = XWhitelistAPI.getFileWhitelist();
    players.forEach(player -> Bukkit.getLogger().info(player));
}
  • boolean isPlayerInWhitelist(String playerName) Checks if a player is in the whitelist (works for both file and MySQL modes).

if (XWhitelistAPI.isPlayerInWhitelist("Steve")) {
    Bukkit.getLogger().info("Steve is whitelisted!");
}
  • void addPlayerToWhitelist(String playerName) Adds a player to the whitelist (file or MySQL).

XWhitelistAPI.addPlayerToWhitelist("Alex");
  • void removePlayerFromWhitelist(String playerName) Removes a player from the whitelist (file or MySQL).

XWhitelistAPI.removePlayerFromWhitelist("Alex");
  • List<String> listWhitelist() Returns a list of all whitelisted players.

public void printWhitelist() {
    List<String> allPlayers = XWhitelistAPI.listWhitelist();
    allPlayers.forEach(player -> Bukkit.getLogger().info(player));
}
  • void clearWhitelist() Clears all entries in the whitelist.

XWhitelistAPI.clearWhitelist();

πŸ› οΈ Maintenance Whitelist Methods

Click to expand
  • boolean isMaintenanceWhitelistActive() Returns whether the maintenance whitelist is enabled.

if (XWhitelistAPI.isMaintenanceWhitelistActive()) {
    Bukkit.getLogger().info("Maintenance whitelist is active!");
}
  • void toggleMaintenanceWhitelist() Toggles the maintenance whitelist status.

XWhitelistAPI.toggleMaintenanceWhitelist();
  • List<String> getMaintenanceWhitelist() Returns the list of players in the maintenance whitelist.

public void printMaintenanceWhitelist() {
    List<String> staff = XWhitelistAPI.getMaintenanceWhitelist();
    staff.forEach(player -> Bukkit.getLogger().info(player));
}
  • boolean isPlayerInMaintenanceWhitelist(String playerName) Checks if a player is in the maintenance whitelist.

if (XWhitelistAPI.isPlayerInMaintenanceWhitelist("Steve")) {
    Bukkit.getLogger().info("Steve is in the maintenance whitelist!");
}
  • void addPlayerToMaintenanceWhitelist(String playerName) Adds a player to the maintenance whitelist.

XWhitelistAPI.addPlayerToMaintenanceWhitelist("Alex");
  • void removePlayerFromMaintenanceWhitelist(String playerName) Removes a player from the maintenance whitelist.

XWhitelistAPI.removePlayerFromMaintenanceWhitelist("Alex");
  • void cleanupMaintenanceWhitelist() Clears all entries in the maintenance whitelist.

XWhitelistAPI.cleanupMaintenanceWhitelist();
  • List<String> listMaintenanceWhitelist() Returns a list of all players in the maintenance whitelist.

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.


πŸ”— References

Last updated