Package com.djrapitops.plan.query
Class QuerySvc
java.lang.Object
com.djrapitops.plan.query.QuerySvc
- All Implemented Interfaces:
QueryService
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.djrapitops.plan.query.QueryService
QueryService.Holder, QueryService.ThrowingConsumer<T>, QueryService.ThrowingFunction<T,R>, QueryService.VoidFunction
-
Constructor Summary
ConstructorDescriptionQuerySvc(PlanConfig config, DBSystem dbSystem, ServerInfo serverInfo, ErrorLogger errorLogger)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Future<?>
execute(String sql, QueryService.ThrowingConsumer<PreparedStatement> performStatement)
Execute SQL against Plan database.Perform some commonly wanted queries.Get what kind of database is in use.Get the UUID of this server.void
playerRemoved(UUID playerUUID)
<T> T
query(String sql, QueryService.ThrowingFunction<PreparedStatement,T> performQuery)
Perform a query against Plan database.void
register()
void
subscribeDataClearEvent(QueryService.VoidFunction eventListener)
Used for getting notified about removal of ALL data.void
subscribeToPlayerRemoveEvent(Consumer<UUID> eventListener)
Used for getting notified about removal of player data.
-
Constructor Details
-
QuerySvc
@Inject public QuerySvc(PlanConfig config, DBSystem dbSystem, ServerInfo serverInfo, ErrorLogger errorLogger)
-
-
Method Details
-
register
public void register() -
getDBType
Description copied from interface:QueryService
Get what kind of database is in use.- Specified by:
getDBType
in interfaceQueryService
- Returns:
- SQLITE or MYSQL
-
query
Description copied from interface:QueryService
Perform a query against Plan database.Blocks thread until query is complete.
- Specified by:
query
in interfaceQueryService
- 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
.
-
execute
public Future<?> execute(String sql, QueryService.ThrowingConsumer<PreparedStatement> performStatement)Description copied from interface:QueryService
Execute SQL against Plan database.Does not block thread, SQL is executed in a single transaction to the database.
Differs from
QueryService.query(String, ThrowingFunction)
in that no results are returned.- Specified by:
execute
in interfaceQueryService
- 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.
-
subscribeToPlayerRemoveEvent
Description copied from interface:QueryService
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 })
- Specified by:
subscribeToPlayerRemoveEvent
in interfaceQueryService
- Parameters:
eventListener
- Functional interface that is called on the event.
-
subscribeDataClearEvent
Description copied from interface:QueryService
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 })
- Specified by:
subscribeDataClearEvent
in interfaceQueryService
- Parameters:
eventListener
- Functional interface that is called on the event.
-
playerRemoved
-
dataCleared
public void dataCleared() -
getServerUUID
Description copied from interface:QueryService
Get the UUID of this server.- Specified by:
getServerUUID
in interfaceQueryService
- Returns:
- Optional of the server UUID, empty if server did not start properly.
-
getCommonQueries
Description copied from interface:QueryService
Perform some commonly wanted queries.- Specified by:
getCommonQueries
in interfaceQueryService
- Returns:
CommonQueries
implementation.
-