Interface QueryService

All Known Implementing Classes:
QuerySvc

public interface QueryService
Service for Query API.

Requires Capability QUERY_API

  • Method Details

    • getInstance

      static QueryService getInstance()
      Obtain instance of QueryService.
      Returns:
      QueryService implementation.
      Throws:
      NoClassDefFoundError - If Plan is not installed and this class can not be found or if older Plan version is installed.
      IllegalStateException - If Plan is installed, but not enabled.
    • getDBType

      String getDBType()
      Get what kind of database is in use.
      Returns:
      SQLITE or MYSQL
      Throws:
      IllegalStateException - If database has not been initialized (Plugin failed to enable)
    • query

      Perform a query against Plan database.

      Blocks thread until query is complete.

      Type Parameters:
      T - Type of results.
      Parameters:
      sql - SQL String to execute, can contain parameterized queries (?).
      performQuery - set your parameters to the PreparedStatement and execute the query, return results.
      Returns:
      The object returned by results.
      Throws:
      IllegalStateException - If something goes wrong with the query. SQLException might be as cause.
    • execute

      Execute SQL against Plan database.

      Does not block thread, SQL is executed in a single transaction to the database.

      Differs from query(String, ThrowingFunction) in that no results are returned.

      Parameters:
      sql - SQL String to execute, can contain parameterized queries (?).
      performStatement - set your parameters to the PreparedStatement and execute the statement.
      Returns:
      A Future that tells when the transaction has completed. Blocks thread if Future#get is called.
      Throws:
      IllegalStateException - If something goes wrong with the query. SQLException might be as cause.
    • subscribeToPlayerRemoveEvent

      void subscribeToPlayerRemoveEvent(Consumer<UUID> eventListener)
      Used for getting notified about removal of player data.

      SQL for removing this player's data should be executed when this occurs.

      Example usage: subscribeToPlayerRemoveEvent(playerUUID -> { do stuff })

      Parameters:
      eventListener - Functional interface that is called on the event.
    • subscribeDataClearEvent

      void subscribeDataClearEvent(QueryService.VoidFunction eventListener)
      Used for getting notified about removal of ALL data.

      SQL for removing all extra tables (and data) should be performed

      Example usage: subscribeDataClearEvent(() -> { do stuff })

      Parameters:
      eventListener - Functional interface that is called on the event.
    • getServerUUID

      Optional<UUID> getServerUUID()
      Get the UUID of this server.
      Returns:
      Optional of the server UUID, empty if server did not start properly.
    • getCommonQueries

      CommonQueries getCommonQueries()
      Perform some commonly wanted queries.
      Returns:
      CommonQueries implementation.
      Throws:
      IllegalStateException - If database has not been initialized (Plugin failed to enable)