miners
This commit is contained in:
parent
0ba5074c30
commit
df59f95c7b
2 changed files with 7 additions and 2 deletions
|
@ -13,6 +13,7 @@ public class DatabaseManager {
|
||||||
private static MongoCollection<Document> custom_weapons;
|
private static MongoCollection<Document> custom_weapons;
|
||||||
public static MongoCollection<Document> ranks;
|
public static MongoCollection<Document> ranks;
|
||||||
public static MongoCollection<Document> npcs;
|
public static MongoCollection<Document> npcs;
|
||||||
|
public static MongoCollection<Document> miners;
|
||||||
public MongoClient client;
|
public MongoClient client;
|
||||||
public static MongoDatabase database;
|
public static MongoDatabase database;
|
||||||
|
|
||||||
|
@ -23,21 +24,25 @@ public class DatabaseManager {
|
||||||
custom_weapons = database.getCollection("custom_weapons");
|
custom_weapons = database.getCollection("custom_weapons");
|
||||||
ranks = database.getCollection("ranks");
|
ranks = database.getCollection("ranks");
|
||||||
npcs = database.getCollection("npcs");
|
npcs = database.getCollection("npcs");
|
||||||
|
miners = database.getCollection("miners");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createUserSchema(String username) {
|
public static void createUserSchema(String username) {
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
document.put("Username", username);
|
document.put("Username", username);
|
||||||
document.put("Bank", 0);
|
document.put("Bank", 0);
|
||||||
users.insertOne(document);
|
users.insertOne(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUserBank(String username, Number coins) {
|
public void updateUserBank(String username, Number coins) {
|
||||||
Document document = users.find(new Document("Username", username)).first();
|
Document document = users.find(new Document("Username", username)).first();
|
||||||
if(document != null) {
|
if (document != null) {
|
||||||
Bson updated = new Document("Bank", coins);
|
Bson updated = new Document("Bank", coins);
|
||||||
Bson update = new Document("$set", updated);
|
Bson update = new Document("$set", updated);
|
||||||
users.updateOne(document, update);
|
users.updateOne(document, update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Object> getUser(String username) {
|
public static HashMap<String, Object> getUser(String username) {
|
||||||
try (MongoCursor<Document> cursor = users.find(Filters.eq("Username", username)).cursor()) {
|
try (MongoCursor<Document> cursor = users.find(Filters.eq("Username", username)).cursor()) {
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
|
|
Loading…
Reference in a new issue