Class BotSentryAPI


  • public class BotSentryAPI
    extends java.lang.Object
    Master class of the API for BotSentry.

    Retrieve the instance of the API using getAPI().

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkIP​(java.lang.String ip)
      Checks the string and returns true if the string is correctly written like IPv4.
      AntiBotSentryMode getAntiBotMode()
      Gives the AntiBot Mode object for handling and retrieving information about AntiBot Mode
      static BotSentryAPI getAPI()
      Gives the instance of the BotSentry API which hooks into the plugin.
      BotSentryList getBlacklist()
      Gives the blacklist object, where operations can be asynchronously scheduled.
      void getCheckedIP​(java.lang.String ip, java.util.function.Consumer<CheckedIP> callback)
      Gives the checked object of the given IP asynchronously.
      void getIPStatus​(java.lang.String ip, java.util.function.Consumer<IPStatus> callback)
      Gives the current status of the given IP asynchronously.
      BotSentryMySQL getMySQL()
      Gives the MySQL values object.
      APIPlatform getPlatform()
      Gives the platform where the plugin is running on.
      BotSentryList getWhitelist()
      Gives the whitelist object, where operations can be asynchronously scheduled.
      void isChecked​(java.lang.String ip, java.util.function.Consumer<java.lang.Boolean> callback)
      Gives the checked status of the given IP asynchronously.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAPI

        public static BotSentryAPI getAPI()
        Gives the instance of the BotSentry API which hooks into the plugin. The instance can be null for these reasons:
        • The plugin is not present on the server
        • The plugin is not enabled on the server
        • An error occurred when it was enabling
        Returns:
        Instance of the com.lahuca.botsentry.api. Can be null for several reasons.
      • checkIP

        public static boolean checkIP​(java.lang.String ip)
        Checks the string and returns true if the string is correctly written like IPv4. IPv4 Requirements:
        • Four sections split by a dot. (XXX.XXX.XXX.XXX)
        • Every section should be a number.
        • Every number must lay between 0 and 255.
        Parameters:
        ip - The string to check for.
        Returns:
        The correctness of the given string.
      • getPlatform

        public APIPlatform getPlatform()
        Gives the platform where the plugin is running on. To make it compatible with later versions, it will return APIPlatform.UNKNOWN if platform is not known in the API.
        Returns:
        The platform the API is running on.
      • getMySQL

        public BotSentryMySQL getMySQL()
        Gives the MySQL values object. Null if MySQL is disabled.
        Returns:
        The MySQL values object or null.
      • getIPStatus

        public void getIPStatus​(java.lang.String ip,
                                java.util.function.Consumer<IPStatus> callback)
                         throws java.lang.IllegalArgumentException
        Gives the current status of the given IP asynchronously. In case of the IPStatus.BLACKLIST and IPStatus.WHITELIST IP status values, it can also have IPStatus.CHECKED, only if AutoPurger for blacklist is enabled (starting from 8.3-ARES); You can confirm this with isChecked(String, Consumer)
        Parameters:
        ip - The IP to retrieve the status from.
        callback - The callback object, it will return the value when it is retrieved asynchronously.
        Throws:
        java.lang.IllegalArgumentException - If the IP is not in the correct IPv4 format.
      • isChecked

        public void isChecked​(java.lang.String ip,
                              java.util.function.Consumer<java.lang.Boolean> callback)
                       throws java.lang.IllegalArgumentException
        Gives the checked status of the given IP asynchronously. This can still give true if the value from getIPStatus(String, Consumer) is IPStatus.WHITELIST or IPStatus.BLACKLIST.

        Starting from 8.3-ARES the checked state has been changed. Now it only stores the checked state when AutoPurger for blacklist is enabled. If it is disabled, it will still return false.

        Parameters:
        ip - The IP to retrieve the checked status from.
        callback - The callback object, it will return the value when it is retrieved asynchronously.
        Throws:
        java.lang.IllegalArgumentException - If the IP is not in the correct IPv4 format.
      • getCheckedIP

        public void getCheckedIP​(java.lang.String ip,
                                 java.util.function.Consumer<CheckedIP> callback)
                          throws java.lang.IllegalArgumentException
        Gives the checked object of the given IP asynchronously. It can also callback null, when the IP is not checked. Or starting from 8.3-ARES, it will also return null, if AutoPurger for blacklist is disabled.
        Parameters:
        ip - The IP to retrieve the checked object from.
        callback - The callback object, it will return the checked object or null when it is retrieved asynchronously.
        Throws:
        java.lang.IllegalArgumentException - If the IP is not in the correct IPv4 format.
      • getWhitelist

        public BotSentryList getWhitelist()
        Gives the whitelist object, where operations can be asynchronously scheduled.
        Returns:
        The whitelist object.
      • getBlacklist

        public BotSentryList getBlacklist()
        Gives the blacklist object, where operations can be asynchronously scheduled.
        Returns:
        The blacklist object.
      • getAntiBotMode

        public AntiBotSentryMode getAntiBotMode()
        Gives the AntiBot Mode object for handling and retrieving information about AntiBot Mode
        Returns:
        The AntiBot Mode object.