Class Database
java.lang.Object
org.reprogle.honeypot.common.storagemanager.sqlite.Database
- Direct Known Subclasses:
SQLite
This is a LARGE class which includes ALL the possible database operations for
Honeypot. Be careful when editing!
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPlayerHistory(org.bukkit.entity.Player p, HoneypotBlockObject block) Add a player to the history databasevoidclose(PreparedStatement ps, ResultSet rs) Close the DB connectionvoidcreateHoneypotBlock(org.bukkit.block.Block block, String action) Create a HoneypotBlock using SQLite.voidcreateHoneypotPlayer(org.bukkit.entity.Player player, int blocksBroken) Creates a Honeypot PlayervoidDelete's all blocks in the DBvoidDelete all player historyvoidDelete's all players from the DBvoiddeletePlayerHistory(org.bukkit.entity.Player p, int... n) Delete a player's most recent history.getAction(org.bukkit.block.Block block) Gets the action of the Honeypot block passesGet all the Honeypot blocks in the DBintgetCount(org.bukkit.entity.Player player) Get's the current number of block the player has brokenintgetCount(org.bukkit.OfflinePlayer player) Get's the current number of block the player has brokenabstract ConnectionbooleanisHoneypotBlock(org.bukkit.block.Block block) Checks if the DB contains the Block passedabstract voidload()voidremoveHoneypotBlock(org.bukkit.block.Block block) Removes a Honeypot block from the DB.retrieveHistory(org.bukkit.entity.Player p) Retrieve all history for a playervoidsetPlayerCount(org.bukkit.entity.Player playerName, int blocksBroken) Sets the player count
-
Constructor Details
-
Database
Create a Database object- Parameters:
instance- The instance of the Honeypot plugin
-
-
Method Details
-
getSQLConnection
-
load
public abstract void load() -
close
Close the DB connection- Parameters:
ps- The PreparedStatementrs- The ResultSet
-
createHoneypotBlock
Create a HoneypotBlock using SQLite. Connects to the DB and inserts the block into it.- Parameters:
block- The Block to add to the DBaction- The action
-
removeHoneypotBlock
public void removeHoneypotBlock(org.bukkit.block.Block block) Removes a Honeypot block from the DB. Connects to the DB and runs a DELETE FROM query- Parameters:
block- The block to remove
-
isHoneypotBlock
public boolean isHoneypotBlock(org.bukkit.block.Block block) Checks if the DB contains the Block passed- Parameters:
block- The Block to check- Returns:
- True if it conains the block, false if it doesn't
-
getAction
Gets the action of the Honeypot block passes- Parameters:
block- The Honeypot block to check- Returns:
- The action in String form
-
getAllHoneypots
Get all the Honeypot blocks in the DB- Returns:
- A list of HoneypotBlockObjects from the DB
-
createHoneypotPlayer
public void createHoneypotPlayer(org.bukkit.entity.Player player, int blocksBroken) Creates a Honeypot Player- Parameters:
player- The Player to createblocksBroken- The number of Blocks the player has broken
-
setPlayerCount
public void setPlayerCount(org.bukkit.entity.Player playerName, int blocksBroken) Sets the player count- Parameters:
playerName- The Player object of the Playe to setblocksBroken- The number of Blocks broken
-
getCount
public int getCount(org.bukkit.entity.Player player) Get's the current number of block the player has broken- Parameters:
player- The Player to check- Returns:
- An int representing how many blocks the player has broken
-
getCount
public int getCount(org.bukkit.OfflinePlayer player) Get's the current number of block the player has broken- Parameters:
player- The OfflinePlayer to check- Returns:
- An int representing how many blocks the player has broken. Returns -1 if the player doesn't exist
-
deleteAllBlocks
public void deleteAllBlocks()Delete's all blocks in the DB -
deleteAllPlayers
public void deleteAllPlayers()Delete's all players from the DB -
deleteAllHistory
public void deleteAllHistory()Delete all player history -
addPlayerHistory
Add a player to the history database- Parameters:
p- The player to addblock- The HoneypotBlock to add
-
retrieveHistory
Retrieve all history for a player- Parameters:
p- The Player to retrieve- Returns:
- An ArrayList of HoneypotPlayerHistory objects for the player
-
deletePlayerHistory
public void deletePlayerHistory(org.bukkit.entity.Player p, int... n) Delete a player's most recent history. An optional 'n' value is listed to allow for deleting a certain number of rows- Parameters:
p- The player to delete history forn- An optional int, representing the number of most recent items to delete. An array may be supplied here, but only index 0 will be used
-