Class LocalIPLookupManager

java.lang.Object
me.remigio07.chatplugin.api.common.ip_lookup.LocalIPLookupManager
All Implemented Interfaces:
ChatPluginManager

public abstract class LocalIPLookupManager extends Object implements ChatPluginManager
Manager that handles IPLookup requests to the local database.

Only used when IPLookupManager.getMethod() == IPLookupMethod.LOCAL.

  • Field Details

  • Constructor Details

    • LocalIPLookupManager

      public LocalIPLookupManager()
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Description copied from interface: ChatPluginManager
      Checks if this manager is enabled.
      Specified by:
      isEnabled in interface ChatPluginManager
      Returns:
      Whether this manager is enabled
    • getCityDatabaseFile

      public File getCityDatabaseFile()
      Gets the MaxMind's city local database file.
      Returns:
      City database file
    • getASNDatabaseFile

      public File getASNDatabaseFile()
      Gets the MaxMind's ASN local database file.
      Returns:
      ASN database file
    • getLockFile

      public File getLockFile()
      Gets the .lock file associated with this server's databases.
      Returns:
      Databases' .lock file
    • getInstance

      public static LocalIPLookupManager getInstance()
      Gets this manager's instance.
      Returns:
      Manager's instance
    • update

      public abstract void update(IPLookup lookup)
      Updates an existing lookup with the local database's information.
      Parameters:
      lookup - Lookup to update
    • downloadDatabase

      public abstract void downloadDatabase(LocalIPLookupManager.DatabaseType type) throws IOException
      Downloads an up to date copy of the database files from MaxMind's website.
      Parameters:
      type - The database to download
      Throws:
      IOException - If something goes wrong
    • formatURL

      public abstract URL formatURL(LocalIPLookupManager.DatabaseType type)
      Formats the MaxMind website's database download URL with your license key.
      Parameters:
      type - The database to download
      Returns:
      direct URL to the database file
    • getCityDatabaseReader

      public abstract Object getCityDatabaseReader()
      Gets the MaxMind's city local database reader.

      This is an instance of DatabaseReader, but the method returns just an Object because you cannot directly access the libraries' classes. You can safely cast it to that class, but make sure the current class loader has loaded it.

      Returns:
      The city database reader
    • getASNDatabaseReader

      public abstract Object getASNDatabaseReader()
      Gets the MaxMind's ASN local database reader.

      This is an instance of DatabaseReader, but the method returns just an Object because you cannot directly access the libraries' classes. You can safely cast it to that class, but make sure the current class loader has loaded it.

      Returns:
      The ASN database reader
    • refreshDatabaseFile

      public abstract void refreshDatabaseFile(LocalIPLookupManager.DatabaseType type) throws IOException
      Refreshes the specified database type's file.

      The following operations (in this order) are performed:

      1. check if the file exists already
      2. if it does, delete it and create a new one
      3. download the .tar.gz database and extract it
      4. transfer its content to the file's location
      Parameters:
      type - Database's type
      Throws:
      IOException - If something goes wrong