doesnt compile

This commit is contained in:
2020-10-27 22:49:56 -05:00
parent f1744f2050
commit f5c5c75ee1
21 changed files with 214 additions and 280 deletions

View File

@ -2,43 +2,36 @@ package me.totalfreedom.plex.storage;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import dev.morphia.Datastore;
import dev.morphia.Morphia;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.player.PlexPlayer;
import org.mongodb.morphia.Datastore;
import org.mongodb.morphia.Morphia;
public class MongoConnection
{
// USE MORPHIA API FOR MONGO <3
private Plex plugin = Plex.get();
private final Plex plugin = Plex.get();
public Datastore getDatastore()
{
if (!plugin.getConfig().getString("data.central.storage").equalsIgnoreCase("mongodb"))
if (!plugin.config().getString("data.central.storage").equalsIgnoreCase("mongodb"))
{
return null;
}
String host = plugin.getConfig().getString("data.central.hostname");
int port = plugin.getConfig().getInt("data.central.port");
String username = plugin.getConfig().getString("data.central.user");
String password = plugin.getConfig().getString("data.central.password");
String database = plugin.getConfig().getString("data.central.db");
String connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/?authSource=" + database;
String host = plugin.config().getString("data.central.hostname");
int port = plugin.config().getInt("data.central.port");
String username = plugin.config().getString("data.central.user");
String password = plugin.config().getString("data.central.password");
String database = plugin.config().getString("data.central.db");
String connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/?authSource=" + database;
MongoClient client = new MongoClient(new MongoClientURI(connectionString));
Morphia morphia = new Morphia();
Datastore datastore = morphia.createDatastore(client, database);
morphia.map(PlexPlayer.class);
datastore.getMapper().addMappedClass(PlexPlayer.class);
datastore.ensureIndexes();
plugin.setStorageType(StorageType.MONGO);
return datastore;
}
}

View File

@ -7,7 +7,6 @@ import redis.clients.jedis.JedisPoolConfig;
public class RedisConnection
{
private JedisPool pool;
private Jedis jedis;

View File

@ -1,45 +1,46 @@
package me.totalfreedom.plex.storage;
import me.totalfreedom.plex.Plex;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import me.totalfreedom.plex.Plex;
public class SQLConnection
{
private Plex plugin = Plex.get();
private final Plex plugin = Plex.get();
private Connection connection;
public Connection getCon()
{
String host = plugin.getConfig().getString("data.central.hostname");
int port = plugin.getConfig().getInt("data.central.port");
String username = plugin.getConfig().getString("data.central.user");
String password = plugin.getConfig().getString("data.central.password");
String database = plugin.getConfig().getString("data.central.db");
String host = plugin.config.getString("data.central.hostname");
int port = plugin.config.getInt("data.central.port");
String username = plugin.config.getString("data.central.user");
String password = plugin.config.getString("data.central.password");
String database = plugin.config.getString("data.central.db");
try {
if (plugin.getConfig().getString("data.central.storage").equalsIgnoreCase("sqlite"))
try
{
if (plugin.config.getString("data.central.storage").equalsIgnoreCase("sqlite"))
{
connection = DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath());
Plex.get().setStorageType(StorageType.SQLITE);
}
else if (plugin.getConfig().getString("data.central.storage").equalsIgnoreCase("mysql"))
else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mysql"))
{
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
Plex.get().setStorageType(StorageType.SQL);
}
} catch (SQLException throwables) {
}
catch (SQLException throwables)
{
throwables.printStackTrace();
}
try {
if (connection != null)
{
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `players` (\n" +
try
{
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `players` (\n" +
"\t`uuid` VARCHAR(46),\n" +
"\t`name` VARCHAR(18),\n" +
"\t`login_msg` VARCHAR(256),\n" +
@ -49,13 +50,11 @@ public class SQLConnection
"\t`coins` BIGINT,\n" +
"\tPRIMARY KEY (`uuid`)\n" +
");").execute();
}
} catch (SQLException throwables) {
}
catch (SQLException throwables)
{
throwables.printStackTrace();
}
return connection;
}
}