This commit is contained in:
NK 2022-11-28 22:27:00 +00:00
parent 0ba5074c30
commit df59f95c7b
2 changed files with 7 additions and 2 deletions

View file

@ -13,6 +13,7 @@ public class DatabaseManager {
private static MongoCollection<Document> custom_weapons;
public static MongoCollection<Document> ranks;
public static MongoCollection<Document> npcs;
public static MongoCollection<Document> miners;
public MongoClient client;
public static MongoDatabase database;
@ -23,21 +24,25 @@ public class DatabaseManager {
custom_weapons = database.getCollection("custom_weapons");
ranks = database.getCollection("ranks");
npcs = database.getCollection("npcs");
miners = database.getCollection("miners");
}
public static void createUserSchema(String username) {
Document document = new Document();
document.put("Username", username);
document.put("Bank", 0);
users.insertOne(document);
}
public void updateUserBank(String username, Number coins) {
Document document = users.find(new Document("Username", username)).first();
if(document != null) {
if (document != null) {
Bson updated = new Document("Bank", coins);
Bson update = new Document("$set", updated);
users.updateOne(document, update);
}
}
public static HashMap<String, Object> getUser(String username) {
try (MongoCursor<Document> cursor = users.find(Filters.eq("Username", username)).cursor()) {
while (cursor.hasNext()) {