java.lang.Object
org.reprogle.honeypot.storagemanager.sqlite.Database
Direct Known Subclasses:
SQLite

public abstract class Database extends Object
  • Constructor Details

    • Database

      protected Database(Honeypot instance)
      Create a Database object
      Parameters:
      instance - The instance of the Honeypot plugin
  • Method Details

    • getSQLConnection

      public abstract Connection getSQLConnection()
    • load

      public abstract void load()
    • initialize

      public void initialize()
      Initialize the Database
    • close

      public void close(PreparedStatement ps, ResultSet rs)
      Close the DB connection
      Parameters:
      ps - The PreparedStatement
      rs - The ResultSet
    • createHoneypotBlock

      public void createHoneypotBlock(org.bukkit.block.Block block, String action)
      Create a HoneypotBlock using SQLite. Connects to the DB and inserts the block into it.
      Parameters:
      block - The Block to add to the DB
      action - 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

      public String getAction(org.bukkit.block.Block block)
      Gets the action of the Honeypot block passes
      Parameters:
      block - The Honeypot block to check
      Returns:
      The action in String form
    • getAllHoneypots

      public List<HoneypotBlockObject> 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 create
      blocksBroken - 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 set
      blocksBroken - The number of Blocks broken
    • getCount

      public int getCount(org.bukkit.entity.Player playerName)
      Get's the current number of block the player has broken
      Parameters:
      playerName - The Player to check
      Returns:
      An int representing how many blocks the player has broken
    • 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

      public void addPlayerHistory(org.bukkit.entity.Player p, HoneypotBlockObject block)
      Add a player to the history database
      Parameters:
      p - The player to add
      block - The HoneypotBlock to add
    • retrieveHistory

      public List<HoneypotPlayerHistoryObject> retrieveHistory(org.bukkit.entity.Player p)
      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 for
      n - 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