mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-29 19:41:24 +01:00
Restructured database
This commit is contained in:
parent
aa93c11080
commit
77b3653547
@ -15,9 +15,9 @@ import us.tastybento.bskyblock.config.PluginConfig;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
|
||||
import us.tastybento.bskyblock.database.IslandsManager;
|
||||
import us.tastybento.bskyblock.database.OfflineHistoryMessages;
|
||||
import us.tastybento.bskyblock.database.PlayersManager;
|
||||
import us.tastybento.bskyblock.database.managers.IslandsManager;
|
||||
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages;
|
||||
import us.tastybento.bskyblock.database.managers.PlayersManager;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.database.objects.Island.SettingsFlag;
|
||||
import us.tastybento.bskyblock.util.VaultHelper;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import us.tastybento.bskyblock.database.BSBDatabase.DatabaseType;
|
||||
import us.tastybento.bskyblock.database.OfflineHistoryMessages.HistoryMessageType;
|
||||
import us.tastybento.bskyblock.database.managers.OfflineHistoryMessages.HistoryMessageType;
|
||||
|
||||
/**
|
||||
* All the plugin settings are here
|
||||
|
@ -3,6 +3,7 @@ package us.tastybento.bskyblock.database;
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.flatfile.FlatFileDatabase;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.mysql.MySQLDatabase;
|
||||
import us.tastybento.bskyblock.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
@ -48,7 +48,6 @@ public interface DatabaseConnecter {
|
||||
* @param tableName - analogous to a table in a database
|
||||
* @param fileName - the name of the record. Must be unique.
|
||||
*/
|
||||
public void saveYamlFile(YamlConfiguration yamlFile, String tableName,
|
||||
String fileName);
|
||||
public void saveYamlFile(YamlConfiguration yamlFile, String tableName, String fileName);
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,12 @@ package us.tastybento.bskyblock.database;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
public class DatabaseConnectionSettingsImpl {
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private String databaseName;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Hosts database settings
|
||||
* @param host
|
||||
@ -17,14 +17,14 @@ public class DatabaseConnectionSettingsImpl {
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public DatabaseConnectionSettingsImpl(String host, int port,
|
||||
String databaseName, String username, String password) {
|
||||
public DatabaseConnectionSettingsImpl(String host, int port, String databaseName, String username, String password) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.databaseName = databaseName;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public DatabaseConnectionSettingsImpl() {
|
||||
this.host = Settings.dbHost;
|
||||
this.port = Settings.dbPort;
|
||||
@ -32,60 +32,70 @@ public class DatabaseConnectionSettingsImpl {
|
||||
this.username = Settings.dbUsername;
|
||||
this.password = Settings.dbPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the host
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param host the host to set
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the databaseName
|
||||
*/
|
||||
public String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param databaseName the databaseName to set
|
||||
*/
|
||||
public void setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password the password to set
|
||||
*/
|
||||
|
@ -1,8 +1,8 @@
|
||||
package us.tastybento.bskyblock.database.flatfile;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
public class FlatFileDatabase extends BSBDatabase{
|
||||
|
@ -17,8 +17,8 @@ import java.util.UUID;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.lang.reflect.Field;
|
||||
@ -7,6 +7,7 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
|
||||
/**
|
||||
* An abstract class that handles insert/select-operations into/from a database
|
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -11,6 +11,7 @@ import org.bukkit.Location;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
/**
|
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
|
||||
/**
|
||||
* Handles offline messaging to players and teams
|
@ -1,7 +1,6 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -9,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.database.objects.Players;
|
||||
import us.tastybento.bskyblock.util.VaultHelper;
|
@ -1,10 +1,12 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.flatfile.FlatFileDatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.database;
|
||||
package us.tastybento.bskyblock.database.managers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
@ -1,20 +1,16 @@
|
||||
package us.tastybento.bskyblock.database.mysql;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnectionSettingsImpl;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
public class MySQLDatabase extends BSBDatabase{
|
||||
|
||||
@Override
|
||||
public AbstractDatabaseHandler<?> getHandler(BSkyBlock plugin, Class<?> type) {
|
||||
|
||||
return new MySQLDatabaseHandler<Island>(plugin, Island.class,
|
||||
new MySqlDatabaseConnecter(new DatabaseConnectionSettingsImpl()));
|
||||
|
||||
return new MySQLDatabaseHandler<Island>(plugin, Island.class, new MySQLDatabaseConnecter(new DatabaseConnectionSettingsImpl()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
|
@ -9,17 +9,17 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||
import us.tastybento.bskyblock.database.DatabaseConnectionSettingsImpl;
|
||||
|
||||
public class MySqlDatabaseConnecter implements DatabaseConnecter {
|
||||
public class MySQLDatabaseConnecter implements DatabaseConnecter {
|
||||
|
||||
private String connectionUrl;
|
||||
private DatabaseConnectionSettingsImpl dbSettings;
|
||||
private Connection connection = null;
|
||||
|
||||
/**
|
||||
* Class for MySQL database connections using the settings provided
|
||||
* @param dbSettings
|
||||
*/
|
||||
public MySqlDatabaseConnecter(
|
||||
DatabaseConnectionSettingsImpl dbSettings) {
|
||||
public MySQLDatabaseConnecter(DatabaseConnectionSettingsImpl dbSettings) {
|
||||
this.dbSettings = dbSettings;
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||
@ -55,8 +55,7 @@ public class MySqlDatabaseConnecter implements DatabaseConnecter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveYamlFile(YamlConfiguration yamlFile, String tableName,
|
||||
String fileName) {
|
||||
public void saveYamlFile(YamlConfiguration yamlFile, String tableName, String fileName) {
|
||||
// Not used
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package us.tastybento.bskyblock.database.objects;
|
||||
|
||||
|
||||
/**
|
||||
* Contains fields that must be in any data object
|
||||
* @author tastybento
|
||||
@ -14,12 +10,12 @@ public abstract class DataObject {
|
||||
/**
|
||||
* @return the uniqueId
|
||||
*/
|
||||
abstract public String getUniqueId();
|
||||
public abstract String getUniqueId();
|
||||
|
||||
/**
|
||||
* @param uniqueId the uniqueId to set
|
||||
*/
|
||||
abstract public void setUniqueId(String uniqueId);
|
||||
public abstract void setUniqueId(String uniqueId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package us.tastybento.bskyblock.database.sqlite;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||
import us.tastybento.bskyblock.database.BSBDatabase;
|
||||
import us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler;
|
||||
|
||||
public class SQLiteDatabase extends BSBDatabase{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user