diff --git a/src/main/java/me/night/nullvalkyrie/Main.java b/src/main/java/me/night/nullvalkyrie/Main.java index 8df2c9d..bc0b9b2 100644 --- a/src/main/java/me/night/nullvalkyrie/Main.java +++ b/src/main/java/me/night/nullvalkyrie/Main.java @@ -31,7 +31,7 @@ public final class Main extends JavaPlugin { Bukkit.getPluginManager().registerEvents(new DamageEffectEvents(this), this); Bukkit.getPluginManager().registerEvents(new NPCEvents(), this); new DiscordClientManager(); - new DatabaseManager(this); + new DatabaseManager(); NPCManager.reloadNPC(); } } diff --git a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java index 52fc228..48423d6 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java @@ -1,8 +1,5 @@ package me.night.nullvalkyrie.commands; -import me.night.nullvalkyrie.Main; -import me.night.nullvalkyrie.database.DatabaseManager; -import me.night.nullvalkyrie.npc.NPCManager; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -17,9 +14,6 @@ public class BetaCommand extends Command { @Override public void onCommand(CommandSender sender, String[] args) { if (sender instanceof Player) { - Player player = (Player) sender; - NPCManager.createNPC(player, "&a&lNK"); - DatabaseManager.getUser("Kaly15"); } } @Override diff --git a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java index 305db67..3bc1264 100644 --- a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java +++ b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java @@ -3,7 +3,6 @@ package me.night.nullvalkyrie.database; import com.mongodb.client.*; import com.mongodb.client.model.Filters; import me.night.nullvalkyrie.Main; -import me.night.nullvalkyrie.database.ranks.RankManager; import org.bson.Document; import org.bson.conversions.Bson; @@ -15,9 +14,8 @@ public class DatabaseManager { public static MongoCollection ranks; public MongoClient client; public static MongoDatabase database; - private Main main; - public DatabaseManager(Main main) { - this.main = main; + + public DatabaseManager() { this.client = MongoClients.create(Main.env.get("MONGODB_URI")); database = client.getDatabase("NullValkyrie"); users = database.getCollection("users"); @@ -42,13 +40,10 @@ public class DatabaseManager { try (MongoCursor cursor = users.find(Filters.eq("Username", username)).cursor()) { while (cursor.hasNext()) { Document doc = cursor.next(); - for (String a : doc.keySet()) { - if (!a.equals("_id")) { - HashMap details = new HashMap<>(); - details.put(a, doc.get(a)); - return details; - } - } + HashMap map = new HashMap<>(); + for (String key : doc.keySet()) map.put(key, doc.get(key)); + map.remove("_id"); + return map; } } return null; diff --git a/src/main/java/me/night/nullvalkyrie/database/ranks/RankManager.java b/src/main/java/me/night/nullvalkyrie/database/ranks/RankManager.java index ed92726..cb351cb 100644 --- a/src/main/java/me/night/nullvalkyrie/database/ranks/RankManager.java +++ b/src/main/java/me/night/nullvalkyrie/database/ranks/RankManager.java @@ -1,10 +1,7 @@ package me.night.nullvalkyrie.database.ranks; -import com.mongodb.client.MongoClients; -import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import com.mongodb.client.model.Filters; -import me.night.nullvalkyrie.Main; import me.night.nullvalkyrie.database.DatabaseManager; import me.night.nullvalkyrie.ui.Rank; import org.bson.Document; @@ -40,9 +37,9 @@ public class RankManager { try (MongoCursor cursor = DatabaseManager.ranks.find(Filters.eq("UUID", uuid.toString())).cursor()) { while (cursor.hasNext()) { Document doc = cursor.next(); - for (String a : doc.keySet()) { - if (a.equals("Rank")) { - return Rank.valueOf((String) doc.get(a)); + for (String key : doc.keySet()) { + if (key.equals("Rank")) { + return Rank.valueOf((String) doc.get(key)); } } }