Remove deprecated BasicDAO and dev.morphia and replace it with the proper dependency

This commit is contained in:
spacerocket62
2020-10-27 20:45:01 -07:00
parent fac87d8c66
commit f1744f2050
7 changed files with 36 additions and 27 deletions

View File

@ -2,10 +2,10 @@ 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
{
@ -33,7 +33,7 @@ public class MongoConnection
Morphia morphia = new Morphia();
Datastore datastore = morphia.createDatastore(client, database);
datastore.getMapper().addMappedClass(PlexPlayer.class);
morphia.map(PlexPlayer.class);
datastore.ensureIndexes();
plugin.setStorageType(StorageType.MONGO);

View File

@ -37,7 +37,9 @@ public class SQLConnection
}
try {
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `players` (\n" +
if (connection != null)
{
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" +
@ -47,6 +49,7 @@ public class SQLConnection
"\t`coins` BIGINT,\n" +
"\tPRIMARY KEY (`uuid`)\n" +
");").execute();
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}