More work on Clans - Clan repository.
This commit is contained in:
parent
1ee16d284d
commit
4812da2cd9
@ -88,7 +88,6 @@ public class CommandCenter implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void AddCommand(ICommand command)
|
||||
{
|
||||
for (String commandRoot : command.Aliases())
|
||||
|
@ -382,6 +382,26 @@ public class ClanInfo
|
||||
_lastOnline = lastOnline;
|
||||
}
|
||||
|
||||
public void saveAlliances()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void saveMembers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void saveTerritories()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void saveBasicInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ClanToken GetToken()
|
||||
{
|
||||
// Update Members
|
||||
|
@ -1,21 +1,57 @@
|
||||
package mineplex.game.clans.clans.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.game.clans.clans.repository.tokens.ClanToken;
|
||||
|
||||
public class ClanRepository extends RepositoryBase
|
||||
{
|
||||
public ClanRepository(JavaPlugin plugin)
|
||||
private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BOOL, dateCreated LONG, lastOnline LONG, PRIMARY KEY (id), INDEX clanName (name));";
|
||||
private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverName VARCHAR(100), chunk VARCHAR(100), safe BOOL, PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverName));";
|
||||
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BOOL, PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||
|
||||
private static String RETRIEVE_START_CLAN_INFO = "SELECT id, name, description, home, admin, dateCreated, lastOnline FROM clans AS c INNER JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE serverName = ?;";
|
||||
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT a.name, role FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId WHERE ac.clanId = ?;";
|
||||
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT cOther.id, cOther.name FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE ac.clanId = ?;";
|
||||
|
||||
private String _serverName;
|
||||
|
||||
public ClanRepository(JavaPlugin plugin, String serverName)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
_serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
executeUpdate(CREATE_CLAN_TABLE);
|
||||
executeUpdate(CREATE_ACCOUNT_CLAN_TABLE);
|
||||
executeUpdate(CREATE_CLAN_TERRITORY_TABLE);
|
||||
executeUpdate(CREATE_CLAN_ALLIANCE_TABLE);
|
||||
}
|
||||
|
||||
public List<ClanToken> retrieveStartupClanInformation()
|
||||
{
|
||||
executeQuery(RETRIEVE_START_CLAN_INFO, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
}
|
||||
|
||||
}, new ColumnVarChar("serverName", 100, _serverName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
@ -16,9 +16,9 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class FieldRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_FIELD_BLOCK_TABLE = "CREATE TABLE IF NOT EXISTS fieldBlock (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), blockId INT, blockData TINYINT, emptyId INT, emptyData TINYINT, stockMax INT, stockRegenTime DOUBLE, loot VARCHAR(100) PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_ORE_TABLE = "CREATE TABLE IF NOT EXISTS fieldOre (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_MONSTER_TABLE = "CREATE TABLE IF NOT EXISTS fieldMonster (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), name VARCHAR(100), type VARCHAR(100), mobMax INT, mobRate DOUBLE, center VARCHAR(100), radius INT, height INT PRIMARY KEY (id), INDEX serverName (server, name));";
|
||||
private static String CREATE_FIELD_BLOCK_TABLE = "CREATE TABLE IF NOT EXISTS fieldBlock (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), blockId INT, blockData TINYINT, emptyId INT, emptyData TINYINT, stockMax INT, stockRegenTime DOUBLE, loot VARCHAR(100), PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_ORE_TABLE = "CREATE TABLE IF NOT EXISTS fieldOre (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverLocation (server, location));";
|
||||
private static String CREATE_FIELD_MONSTER_TABLE = "CREATE TABLE IF NOT EXISTS fieldMonster (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), name VARCHAR(100), type VARCHAR(100), mobMax INT, mobRate DOUBLE, center VARCHAR(100), radius INT, height INT, PRIMARY KEY (id), INDEX serverName (server, name));";
|
||||
private static String RETRIEVE_FIELD_BLOCKS = "SELECT server, location, blockId, blockData, emptyId, emptyData, stockMax, stockRegen, loot FROM fieldBlock WHERE server = ?;";
|
||||
private static String ADD_FIELD_BLOCK = "INSERT INTO fieldBlock (server, location, blockId, blockData, emptyId, emptyData, stockMax, stockRegen, loot) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
private static String DEL_FIELD_BLOCK = "DELETE FROM fieldBlock WHERE server = ? AND location = ?;";
|
||||
|
Loading…
Reference in New Issue
Block a user