From f0a065dd74584b758abef77e3729922cf61d2610 Mon Sep 17 00:00:00 2001 From: NK Date: Mon, 28 Nov 2022 22:31:36 +0000 Subject: [PATCH] database managers --- .../database/CustomWeaponsDataManager.java | 4 +++ .../database/MinerDataManager.java | 28 +++++++++++++++++++ .../database/UserDataManager.java | 4 +++ 3 files changed, 36 insertions(+) create mode 100644 src/main/java/me/night/nullvalkyrie/database/CustomWeaponsDataManager.java create mode 100644 src/main/java/me/night/nullvalkyrie/database/MinerDataManager.java create mode 100644 src/main/java/me/night/nullvalkyrie/database/UserDataManager.java diff --git a/src/main/java/me/night/nullvalkyrie/database/CustomWeaponsDataManager.java b/src/main/java/me/night/nullvalkyrie/database/CustomWeaponsDataManager.java new file mode 100644 index 0000000..3fb92c1 --- /dev/null +++ b/src/main/java/me/night/nullvalkyrie/database/CustomWeaponsDataManager.java @@ -0,0 +1,4 @@ +package me.night.nullvalkyrie.database; + +public class CustomWeaponsDataManager { +} diff --git a/src/main/java/me/night/nullvalkyrie/database/MinerDataManager.java b/src/main/java/me/night/nullvalkyrie/database/MinerDataManager.java new file mode 100644 index 0000000..7a57f72 --- /dev/null +++ b/src/main/java/me/night/nullvalkyrie/database/MinerDataManager.java @@ -0,0 +1,28 @@ +package me.night.nullvalkyrie.database; + +import org.bson.Document; +import org.bson.conversions.Bson; +import org.bukkit.Material; + +public class MinerDataManager { + public static void setNPC(String name, Material material, int level, double rate, boolean enabled, long lastclaim) { + Document newDocument = new Document(); + newDocument.put("ID", DatabaseManager.miners.countDocuments() + 1); + newDocument.put("Name", name); + newDocument.put("Material", material.name()); + newDocument.put("Level", level); + newDocument.put("Rate", rate); + newDocument.put("Enabled", enabled); + newDocument.put("LastClaim", lastclaim); + DatabaseManager.miners.insertOne(newDocument); + } + public static void setLastclaim(int id) { + Document document = DatabaseManager.miners.find(new Document("ID", id)).first(); + if (document != null) { + Bson updated = new Document("LastClaim", System.currentTimeMillis()); + Bson update = new Document("$set", updated); + DatabaseManager.miners.updateOne(document, update); + } + } +} + diff --git a/src/main/java/me/night/nullvalkyrie/database/UserDataManager.java b/src/main/java/me/night/nullvalkyrie/database/UserDataManager.java new file mode 100644 index 0000000..eb97446 --- /dev/null +++ b/src/main/java/me/night/nullvalkyrie/database/UserDataManager.java @@ -0,0 +1,4 @@ +package me.night.nullvalkyrie.database; + +public class UserDataManager { +}