public abstract class Database extends Object implements Runnable
| Modifier and Type | Field and Description |
|---|---|
protected static String |
BLOCK_TABLE |
protected Connection |
connection |
protected boolean |
disable |
protected static String |
ENTITY_ID_COLUMN |
protected static String |
ENTITY_TABLE |
protected Object |
LOCK |
protected Output |
output |
protected static String |
PLAYER_ID_COLUMN |
protected ConcurrentLinkedQueue<DatabaseAction> |
queue |
protected static String |
WORLD_COLUMN |
protected static String |
X_COLUMN |
protected static String |
Y_COLUMN |
protected static String |
Z_COLUMN |
| Modifier | Constructor and Description |
|---|---|
protected |
Database(Output output) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
close()
Close connection
|
void |
disable()
Disables database as soon as queue is empty and cache is flushed.
|
protected void |
dropDatabaseUserData(User user)
Accesses the database and drops all data related to the specified user
|
void |
enqueue(DatabaseAction databaseAction)
Enqueues an DatabaseAction
|
protected boolean |
flushDatabase(Map<Ownable,User> cacheData)
Flush cache data to database.
|
protected abstract String |
generateCreateBlockTableQuery() |
protected abstract String |
generateCreateEntityTableQuery() |
protected abstract String |
generateDeleteOwnerQuery(OwnedBlock block) |
protected abstract String |
generateDeleteOwnerQuery(OwnedEntity entity) |
protected abstract String |
generateDropUserBlocksQuery(User user) |
protected abstract String |
generateDropUserEntitiesQuery(User user) |
protected abstract String |
generateGetOwnerQuery(OwnedBlock block) |
protected abstract String |
generateGetOwnerQuery(OwnedEntity entity) |
protected abstract String |
generateSetBlockOwnerQuery(DatabaseAction databaseAction)
Generates a sql query to set a new owner for a block
|
protected abstract String |
generateSetEntityOwnerQuery(DatabaseAction databaseAction)
Generates a sql query to set a new owner for a entity
|
protected User |
getDatabaseOwner(Ownable ownable)
Accesses the database and searches for the owner
|
protected Output |
getOutput() |
User |
getOwner(Ownable ownable)
Gets the owner of an Ownable.
|
void |
run() |
protected boolean |
setDatabaseOwner(DatabaseAction databaseAction)
Accesses the database and sets the owner of the Ownable
|
protected static final String PLAYER_ID_COLUMN
protected static final String WORLD_COLUMN
protected static final String ENTITY_ID_COLUMN
protected static final String X_COLUMN
protected static final String Y_COLUMN
protected static final String Z_COLUMN
protected static final String BLOCK_TABLE
protected static final String ENTITY_TABLE
protected final ConcurrentLinkedQueue<DatabaseAction> queue
protected volatile boolean disable
protected final Object LOCK
protected final Output output
protected Connection connection
protected Database(Output output)
protected Output getOutput()
public final void enqueue(DatabaseAction databaseAction)
databaseAction - public User getOwner(Ownable ownable)
ownable - the ownablepublic final void disable()
protected User getDatabaseOwner(Ownable ownable)
ownable - Ownable of which the owner is searchedprotected boolean setDatabaseOwner(DatabaseAction databaseAction)
databaseAction - the DatabaseAction to be performedprotected void dropDatabaseUserData(User user)
user - the Userprotected boolean flushDatabase(Map<Ownable,User> cacheData)
cacheData - the cache dataprotected void close()
protected abstract String generateCreateEntityTableQuery()
protected abstract String generateCreateBlockTableQuery()
protected abstract String generateGetOwnerQuery(OwnedBlock block)
protected abstract String generateGetOwnerQuery(OwnedEntity entity)
protected abstract String generateSetBlockOwnerQuery(DatabaseAction databaseAction)
databaseAction - Guaranteed to have DatabaseActionType OWN and user != User.nobodyprotected abstract String generateSetEntityOwnerQuery(DatabaseAction databaseAction)
databaseAction - Guaranteed to have DatabaseActionType OWN and user != User.nobodyprotected abstract String generateDeleteOwnerQuery(OwnedEntity entity)
protected abstract String generateDeleteOwnerQuery(OwnedBlock block)
Copyright © 2015. All rights reserved.