Skip to content

Commit

Permalink
Completed and tested FlatFile database system
Browse files Browse the repository at this point in the history
  • Loading branch information
funkemunky committed Jan 27, 2019
1 parent e2fc85a commit e725ed0
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 59 deletions.
112 changes: 57 additions & 55 deletions API/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified API/out/artifacts/Atlas_jar/Atlas.jar
Binary file not shown.
Binary file modified API/out/production/Atlas/cc/funkemunky/api/database/Database.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion API/src/cc/funkemunky/api/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
public abstract class Database {
private String name;
private Plugin plugin;
private DatabaseType type;
private Map<String, Object> databaseValues;

public Database(String name, Plugin plugin) {
public Database(String name, Plugin plugin, DatabaseType type) {
this.name = name;
this.plugin = plugin;
this.type = type;

databaseValues = new ConcurrentHashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.funkemunky.api.database.flatfile;

import cc.funkemunky.api.database.Database;
import cc.funkemunky.api.database.DatabaseType;
import cc.funkemunky.api.utils.FunkeFile;
import cc.funkemunky.api.utils.MiscUtils;
import lombok.Getter;
Expand All @@ -12,7 +13,7 @@
public class FlatfileDatabase extends Database {
private FunkeFile file;
public FlatfileDatabase(String name, Plugin plugin) {
super(name, plugin);
super(name, plugin, DatabaseType.FLATFILE);

file = new FunkeFile(plugin, "databases", name + ".txt");
}
Expand Down
5 changes: 3 additions & 2 deletions API/src/cc/funkemunky/api/database/mongo/MongoDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.funkemunky.api.Atlas;
import cc.funkemunky.api.database.Database;
import cc.funkemunky.api.database.DatabaseType;
import cc.funkemunky.api.mongo.Mongo;
import com.mongodb.Block;
import com.mongodb.client.MongoCollection;
Expand All @@ -15,7 +16,7 @@
public class MongoDatabase extends Database {
private MongoCollection<Document> collection;
public MongoDatabase(String name, Plugin plugin) {
super(name, plugin);
super(name, plugin, DatabaseType.MONGO);

collection = Atlas.getInstance().getMongo().getMongoDatabase().getCollection(name);
}
Expand All @@ -31,7 +32,7 @@ public void loadDatabase() {
public void saveDatabase() {
Map<String, Map<String, Object>> toSort = new HashMap<>();
getDatabaseValues().keySet().forEach(key -> {
String[] toFormat = key.split(".");
String[] toFormat = key.split(";");

Map<String, Object> objects = toSort.getOrDefault(toFormat[0], new HashMap<>());

Expand Down

0 comments on commit e725ed0

Please sign in to comment.