diff --git a/.gitignore b/.gitignore
index 4788b4b..dc49dbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,3 +111,4 @@ buildNumber.properties
# Common working directory
run/
+.env
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f54f7ba..bcdbb17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,5 +101,10 @@
4.7.0
provided
+
+ io.github.cdimascio
+ dotenv-java
+ 2.3.1
+
diff --git a/src/main/java/me/night/nullvalkyrie/Main.java b/src/main/java/me/night/nullvalkyrie/Main.java
index ebd4c1f..b64bcfa 100644
--- a/src/main/java/me/night/nullvalkyrie/Main.java
+++ b/src/main/java/me/night/nullvalkyrie/Main.java
@@ -1,73 +1,39 @@
package me.night.nullvalkyrie;
+import io.github.cdimascio.dotenv.Dotenv;
import me.night.nullvalkyrie.chests.MenuListener;
import me.night.nullvalkyrie.discord.DiscordClientManager;
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
-import me.night.nullvalkyrie.events.CustomItemEvents;
-import me.night.nullvalkyrie.events.DamageEffect;
+import me.night.nullvalkyrie.events.*;
import me.night.nullvalkyrie.items.CustomItemManager;
-import me.night.nullvalkyrie.npc.ClickNPC;
-import me.night.nullvalkyrie.npc.NPC;
-import me.night.nullvalkyrie.npc.PacketInjector;
-import me.night.nullvalkyrie.rank.ScoreboardListener;
-import me.night.nullvalkyrie.util.FileManager;
-import me.night.nullvalkyrie.util.Util;
+import me.night.nullvalkyrie.npc.*;
+import me.night.nullvalkyrie.ui.ScoreboardListener;
+import me.night.nullvalkyrie.util.*;
import me.night.nullvalkyrie.commands.*;
import me.night.nullvalkyrie.database.DatabaseManager;
import org.bukkit.*;
-import org.bukkit.boss.BarColor;
-import org.bukkit.boss.BarStyle;
-import org.bukkit.boss.BossBar;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
+public final class Main extends JavaPlugin {
-import java.io.File;
-
-public final class Main extends JavaPlugin implements Listener {
- private BossBar bossbar;
- private PacketInjector injector;
@Override
public void onEnable() {
getConfig().options().copyDefaults();
saveDefaultConfig();
+// Dotenv env = Dotenv.configure().directory("C:\\Users\\NK\\OneDrive\\Desktop\\.nky\\Coding\\Java\\NullValkyrie\\src\\main\\resources").filename(".env").load();
+// System.out.println(env.get("MONGO"));
EnchantmentManager.register();
new CustomItemManager(this);
new FileManager();
new CommandManager(this).register();
- bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
- Bukkit.getPluginManager().registerEvents(this, this);
+ Bukkit.getPluginManager().registerEvents(new ServerEvents(), this);
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this);
Bukkit.getPluginManager().registerEvents(new CustomItemEvents(this), this);
- Bukkit.getPluginManager().registerEvents(new DamageEffect(this), this);
- Bukkit.getPluginManager().registerEvents(new ClickNPC(), this);
- //Bukkit.getPluginManager().registerEvents(new GameEvent(this), this);
+ Bukkit.getPluginManager().registerEvents(new DamageEffectEvents(this), this);
+ Bukkit.getPluginManager().registerEvents(new NPCEvents(), this);
new DiscordClientManager();
- new DatabaseManager();
+ new DatabaseManager(this);
NPC.loadNPC(CustomItemManager.loadConfig("npcs.yml"));
- this.injector = new PacketInjector();
- }
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- bossbar.addPlayer(e.getPlayer());
- injector.addPlayer(e.getPlayer());
- }
-
- @EventHandler
- public void onPing(ServerListPingEvent e) {
- e.setMaxPlayers(8964);
- String s = Util.centerText("Matrix", 45);
- String s2 = Util.centerText("Support 1.18 & 1.8.9", 45);
- e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + "\n" + ChatColor.GOLD + ChatColor.BOLD + s2);
- try {
- e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png")));
- } catch (Exception ee) {
- ee.printStackTrace();
- }
-
}
}
diff --git a/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java b/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java
index 706613c..ea84e2b 100644
--- a/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java
+++ b/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java
@@ -2,8 +2,7 @@ package me.night.nullvalkyrie.commands;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-import me.night.nullvalkyrie.Main;
-import me.night.nullvalkyrie.rank.Rank;
+import me.night.nullvalkyrie.ui.Rank;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@@ -16,7 +15,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import static me.night.nullvalkyrie.rank.ScoreboardListener.rankManager;
+import static me.night.nullvalkyrie.ui.ScoreboardListener.rankManager;
public class RankCommand extends Command {
@@ -37,30 +36,30 @@ public class RankCommand extends Command {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!cooldown.asMap().containsKey(player.getUniqueId())) {
- if (player.isOp()) {
- if (args.length == 2) {
- if (Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
- OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
- for (Rank rank : Rank.values()) {
- if (rank.name().equalsIgnoreCase(args[1])) {
- rankManager.setRank(target.getUniqueId(), rank);
- player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
- if (target.isOnline()) {
- target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
- }
- return;
+ if (!player.isOp()) {
+ player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
+ return;
+ }
+ if (args.length == 2) {
+ if (Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
+ OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
+ for (Rank rank : Rank.values()) {
+ if (rank.name().equalsIgnoreCase(args[1])) {
+ rankManager.setRank(target.getUniqueId(), rank);
+ player.sendMessage(ChatColor.GREEN + "You changed " + target.getName() + "'s rank to " + rank.getDisplay());
+ if (target.isOnline()) {
+ target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay());
}
-
+ return;
}
- player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
- } else {
- player.sendMessage("This player has never played in this server before!");
+
}
+ player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER");
} else {
- player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank ");
+ player.sendMessage("This player has never played in this server before!");
}
} else {
- player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
+ player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank ");
}
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
} else {
diff --git a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java
index a0f3023..b531786 100644
--- a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java
+++ b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java
@@ -3,6 +3,7 @@ package me.night.nullvalkyrie.database;
import com.mongodb.MongoException;
import com.mongodb.client.*;
import com.mongodb.client.model.Filters;
+import me.night.nullvalkyrie.Main;
import org.bson.Document;
import org.bson.conversions.Bson;
@@ -10,15 +11,18 @@ import java.util.HashMap;
public class DatabaseManager {
private static MongoCollection users;
- public DatabaseManager() {
+ private Main main;
+ public DatabaseManager(Main main) {
+ this.main = main;
connect();
}
public void connect() {
- try (MongoClient client = MongoClients.create("mongodb+srv://cath_exe:gaeismypassion@cath-exe.iolb7.mongodb.net/NullValkyrie")) {
-
- } catch (MongoException e) {
- System.out.println("An error occurred when logging in to MongoDB" + e);
- }
+// System.out.println(System.getenv("MONGO"));
+// try (MongoClient client = MongoClients.create(System.getenv("MONGO"))) {
+//
+// } catch (MongoException e) {
+// System.out.println("An error occurred when logging in to MongoDB" + e);
+// }
MongoClient client = MongoClients.create("mongodb+srv://cath_exe:gaeismypassion@cath-exe.iolb7.mongodb.net/NullValkyrie");
MongoDatabase database = client.getDatabase("NullValkyrie");
users = database.getCollection("users");
diff --git a/src/main/java/me/night/nullvalkyrie/events/DamageEffect.java b/src/main/java/me/night/nullvalkyrie/events/DamageEffectEvents.java
similarity index 96%
rename from src/main/java/me/night/nullvalkyrie/events/DamageEffect.java
rename to src/main/java/me/night/nullvalkyrie/events/DamageEffectEvents.java
index 0594654..40e8324 100644
--- a/src/main/java/me/night/nullvalkyrie/events/DamageEffect.java
+++ b/src/main/java/me/night/nullvalkyrie/events/DamageEffectEvents.java
@@ -17,10 +17,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.text.DecimalFormat;
import java.util.*;
-public class DamageEffect implements Listener {
+public class DamageEffectEvents implements Listener {
private final Main main;
- public DamageEffect(Main main) {
+ public DamageEffectEvents(Main main) {
this.main = main;
}
@@ -63,7 +63,7 @@ public class DamageEffect implements Listener {
ticksLeft--;
indicators.put(stand, ticksLeft);
}
- stands.removeAll(removal);
+ removal.forEach(stands::remove);
}
}.runTaskTimer(main, 0L, 1L);
}
diff --git a/src/main/java/me/night/nullvalkyrie/events/ServerEvents.java b/src/main/java/me/night/nullvalkyrie/events/ServerEvents.java
new file mode 100644
index 0000000..8c17b0c
--- /dev/null
+++ b/src/main/java/me/night/nullvalkyrie/events/ServerEvents.java
@@ -0,0 +1,42 @@
+package me.night.nullvalkyrie.events;
+
+import me.night.nullvalkyrie.npc.PacketInjector;
+import me.night.nullvalkyrie.util.Util;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.boss.BarColor;
+import org.bukkit.boss.BarStyle;
+import org.bukkit.boss.BossBar;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.server.ServerListPingEvent;
+
+import java.io.File;
+
+public class ServerEvents implements Listener {
+ public BossBar bossbar;
+ public PacketInjector injector;
+ public ServerEvents() {
+ bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
+ this.injector = new PacketInjector();
+ }
+ @EventHandler
+ public void onJoin(PlayerJoinEvent e) {
+ bossbar.addPlayer(e.getPlayer());
+ injector.addPlayer(e.getPlayer());
+ }
+ @EventHandler
+ public void onPing(ServerListPingEvent e) {
+ e.setMaxPlayers(8964);
+ String s = Util.centerText("Vanadium", 45);
+ String s2 = Util.centerText("Support 1.19.2", 45);
+ e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + "\n" + ChatColor.GOLD + ChatColor.BOLD + s2);
+ try {
+ e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png")));
+ } catch (Exception ee) {
+ ee.printStackTrace();
+ }
+
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/npc/ClickNPC.java b/src/main/java/me/night/nullvalkyrie/npc/ClickNPC.java
deleted file mode 100644
index 8861799..0000000
--- a/src/main/java/me/night/nullvalkyrie/npc/ClickNPC.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package me.night.nullvalkyrie.npc;
-
-import me.night.nullvalkyrie.util.Util;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-
-public class ClickNPC implements Listener {
- @EventHandler
- public void onClick(RightClickNPC e) {
- Player player = e.getPlayer();
- if (e.getNPC().getBukkitEntity().getName().equalsIgnoreCase(Util.color("&a&lNK"))) {
- player.sendMessage(Util.color("Hi"));
- }
- }
-}
diff --git a/src/main/java/me/night/nullvalkyrie/npc/NPCEvents.java b/src/main/java/me/night/nullvalkyrie/npc/NPCEvents.java
new file mode 100644
index 0000000..d4c835f
--- /dev/null
+++ b/src/main/java/me/night/nullvalkyrie/npc/NPCEvents.java
@@ -0,0 +1,34 @@
+package me.night.nullvalkyrie.npc;
+
+import me.night.nullvalkyrie.util.Util;
+import net.minecraft.network.protocol.game.PacketPlayOutEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation;
+import net.minecraft.server.network.PlayerConnection;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerMoveEvent;
+
+public class NPCEvents implements Listener {
+ @EventHandler
+ public void onClick(RightClickNPC e) {
+ Player player = e.getPlayer();
+ if (e.getNPC().getBukkitEntity().getName().equalsIgnoreCase(Util.color("&a&lNK"))) {
+ player.sendMessage(Util.color("Hi"));
+ }
+ }
+ @EventHandler
+ public void onMove(PlayerMoveEvent e) {
+ NPC.getNPCs().stream().forEach(npc -> {
+ Location location = npc.getBukkitEntity().getLocation();
+ location.setDirection(e.getPlayer().getLocation().subtract(location).toVector());
+ float yaw = location.getYaw();
+ float pitch = location.getPitch();
+ PlayerConnection con = ((CraftPlayer) e.getPlayer()).getHandle().b;
+ con.a(new PacketPlayOutEntityHeadRotation(npc, (byte) ((yaw%360)*256/360)));
+ con.a(new PacketPlayOutEntity.PacketPlayOutEntityLook(npc.ae(), (byte) ((yaw%360)*256/360), (byte) ((pitch%360)*256/360), false));
+ });
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/Rank.java b/src/main/java/me/night/nullvalkyrie/rank/Rank.java
deleted file mode 100644
index 72c9c43..0000000
--- a/src/main/java/me/night/nullvalkyrie/rank/Rank.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package me.night.nullvalkyrie.rank;
-
-import org.bukkit.ChatColor;
-
-public enum Rank {
- OWNER(ChatColor.DARK_RED + "{OWNER}"),
- ADMIN(ChatColor.RED + "{ADMIN}"),
- SPECIAL(ChatColor.GOLD + "{SPECIAL}"),
- ROOKIE(ChatColor.DARK_GREEN + "{ROOKIE}");
-
- private String display;
-
- Rank(String display) {
- this.display = display;
- }
-
- public String getDisplay() {
- return display;
- }
-}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/AnimatedSideBar.java b/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java
similarity index 70%
rename from src/main/java/me/night/nullvalkyrie/rank/AnimatedSideBar.java
rename to src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java
index baa2110..dcb4d07 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/AnimatedSideBar.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java
@@ -1,4 +1,4 @@
-package me.night.nullvalkyrie.rank;
+package me.night.nullvalkyrie.ui;
import org.bukkit.Bukkit;
@@ -7,7 +7,7 @@ import java.util.Map;
import java.util.UUID;
public class AnimatedSideBar {
- private static Map Tasks = new HashMap<>();
+ private static final Map Tasks = new HashMap<>();
private final UUID uuid;
public AnimatedSideBar(UUID uuid) {
@@ -17,9 +17,7 @@ public class AnimatedSideBar {
Tasks.put(uuid, id);
}
public boolean hasID() {
- if (Tasks.containsKey(uuid))
- return true;
- return false;
+ return Tasks.containsKey(uuid);
}
public void stop() {
Bukkit.getScheduler().cancelTask(Tasks.get(uuid));
diff --git a/src/main/java/me/night/nullvalkyrie/rank/BelowNameManager.java b/src/main/java/me/night/nullvalkyrie/ui/BelowNameManager.java
similarity index 81%
rename from src/main/java/me/night/nullvalkyrie/rank/BelowNameManager.java
rename to src/main/java/me/night/nullvalkyrie/ui/BelowNameManager.java
index 454575e..444199c 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/BelowNameManager.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/BelowNameManager.java
@@ -1,18 +1,18 @@
-package me.night.nullvalkyrie.rank;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.DisplaySlot;
-import org.bukkit.scoreboard.Objective;
-import org.bukkit.scoreboard.Scoreboard;
-
-public class BelowNameManager {
- public void setBelowName(Player player) {
- Scoreboard board = player.getScoreboard();
- Objective obj = board.registerNewObjective("HealthBar", "health");
- obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
- obj.setDisplayName(ChatColor.RED + "❤");
- player.setScoreboard(board);
- player.setHealth(player.getHealth());
- }
-}
+package me.night.nullvalkyrie.ui;
+
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.Criteria;
+import org.bukkit.scoreboard.DisplaySlot;
+import org.bukkit.scoreboard.Objective;
+import org.bukkit.scoreboard.Scoreboard;
+
+public class BelowNameManager {
+ public void setBelowName(Player player) {
+ Scoreboard board = player.getScoreboard();
+ Objective obj = board.registerNewObjective("HealthBar", Criteria.HEALTH, ChatColor.RED + "❤");
+ obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
+ player.setScoreboard(board);
+ player.setHealth(player.getHealth());
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/NameTagManager.java b/src/main/java/me/night/nullvalkyrie/ui/NameTagManager.java
similarity index 76%
rename from src/main/java/me/night/nullvalkyrie/rank/NameTagManager.java
rename to src/main/java/me/night/nullvalkyrie/ui/NameTagManager.java
index e38ac09..1d5ad9c 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/NameTagManager.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/NameTagManager.java
@@ -1,45 +1,35 @@
-package me.night.nullvalkyrie.rank;
-
-import me.night.nullvalkyrie.Main;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.DisplaySlot;
-import org.bukkit.scoreboard.Objective;
-import org.bukkit.scoreboard.Scoreboard;
-import org.bukkit.scoreboard.Team;
-
-public class NameTagManager {
- private Main main;
-
- public NameTagManager(Main main) {
- this.main = main;
- }
- @SuppressWarnings("deprecation")
- public void setNametags(Player player) {
- Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
- Objective obj = newScoreboard.registerNewObjective("TabList", "dummy");
- obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
- player.setScoreboard(newScoreboard);
- for (Rank rank : Rank.values()) {
- Team team = player.getScoreboard().registerNewTeam(rank.name());
- team.setPrefix(rank.getDisplay() + " ");
- }
- for (Player target : Bukkit.getOnlinePlayers()) {
- if (player.getUniqueId() != target.getUniqueId()) {
- Rank rank = ScoreboardListener.rankManager.getRank(target.getUniqueId());
- player.getScoreboard().getTeam(rank.name()).addEntry(target.getName());
- }
- }
- }
- public void newTag(Player player) {
- Rank rank = ScoreboardListener.rankManager.getRank(player.getUniqueId());
- for(Player target : Bukkit.getOnlinePlayers()) {
- target.getScoreboard().getTeam(rank.name()).addEntry(player.getName());
- }
- }
- public void removeTag(Player player) {
- for(Player target : Bukkit.getOnlinePlayers()) {
- target.getScoreboard().getEntryTeam(player.getName()).removeEntry(player.getName());
- }
- }
-}
+package me.night.nullvalkyrie.ui;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.*;
+
+public class NameTagManager {
+ public void setNametags(Player player) {
+ Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
+ Objective obj = newScoreboard.registerNewObjective("TabList", Criteria.DUMMY, "");
+ obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
+ player.setScoreboard(newScoreboard);
+ for (Rank rank : Rank.values()) {
+ Team team = player.getScoreboard().registerNewTeam(rank.name());
+ team.setPrefix(rank.getDisplay() + " ");
+ }
+ for (Player target : Bukkit.getOnlinePlayers()) {
+ if (player.getUniqueId() != target.getUniqueId()) {
+ Rank rank = ScoreboardListener.rankManager.getRank(target.getUniqueId());
+ player.getScoreboard().getTeam(rank.name()).addEntry(target.getName());
+ }
+ }
+ }
+ public void newTag(Player player) {
+ Rank rank = ScoreboardListener.rankManager.getRank(player.getUniqueId());
+ for(Player target : Bukkit.getOnlinePlayers()) {
+ target.getScoreboard().getTeam(rank.name()).addEntry(player.getName());
+ }
+ }
+ public void removeTag(Player player) {
+ for(Player target : Bukkit.getOnlinePlayers()) {
+ target.getScoreboard().getEntryTeam(player.getName()).removeEntry(player.getName());
+ }
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/ui/Rank.java b/src/main/java/me/night/nullvalkyrie/ui/Rank.java
new file mode 100644
index 0000000..4faba34
--- /dev/null
+++ b/src/main/java/me/night/nullvalkyrie/ui/Rank.java
@@ -0,0 +1,20 @@
+package me.night.nullvalkyrie.ui;
+
+import org.bukkit.ChatColor;
+
+public enum Rank {
+ OWNER(ChatColor.DARK_RED + ""),
+ ADMIN(ChatColor.RED + ""),
+ SPECIAL(ChatColor.GOLD + ""),
+ ROOKIE(ChatColor.DARK_GREEN + "");
+
+ private final String display;
+
+ Rank(String display) {
+ this.display = display;
+ }
+
+ public String getDisplay() {
+ return display;
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/RankManager.java b/src/main/java/me/night/nullvalkyrie/ui/RankManager.java
similarity index 81%
rename from src/main/java/me/night/nullvalkyrie/rank/RankManager.java
rename to src/main/java/me/night/nullvalkyrie/ui/RankManager.java
index 16be626..40b8c4c 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/RankManager.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/RankManager.java
@@ -1,52 +1,48 @@
-package me.night.nullvalkyrie.rank;
-
-import me.night.nullvalkyrie.Main;
-import org.bukkit.Bukkit;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.UUID;
-
-import static me.night.nullvalkyrie.rank.ScoreboardListener.nameTagManager;
-
-public class RankManager {
- private File file;
- private YamlConfiguration config;
-
- private Main main;
-
- public RankManager(Main main) {
- this.main = main;
- if(!main.getDataFolder().exists()) {
- main.getDataFolder().mkdir();
- }
- file = new File(main.getDataFolder(), "ranks.yml");
- if(!file.exists()) {
- try {
- file.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- config = YamlConfiguration.loadConfiguration(file);
- }
- public void setRank(UUID uuid, Rank rank) {
- config.set(uuid.toString(), rank.name());
- try {
- config.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- for(Player player : Bukkit.getOnlinePlayers()) {
- if(player.hasPlayedBefore()) {
- nameTagManager.removeTag(player);
- nameTagManager.newTag(player);
- }
- }
- }
- public Rank getRank(UUID uuid) {
- return Rank.valueOf(config.getString(uuid.toString()));
- }
-}
+package me.night.nullvalkyrie.ui;
+
+import me.night.nullvalkyrie.Main;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.UUID;
+
+import static me.night.nullvalkyrie.ui.ScoreboardListener.nameTagManager;
+
+public class RankManager {
+ private final File file;
+ private final YamlConfiguration config;
+ public RankManager(Main main) {
+ if(!main.getDataFolder().exists()) {
+ main.getDataFolder().mkdir();
+ }
+ file = new File(main.getDataFolder(), "ranks.yml");
+ if(!file.exists()) {
+ try {
+ file.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ config = YamlConfiguration.loadConfiguration(file);
+ }
+ public void setRank(UUID uuid, Rank rank) {
+ config.set(uuid.toString(), rank.name());
+ try {
+ config.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ for(Player player : Bukkit.getOnlinePlayers()) {
+ if(player.hasPlayedBefore()) {
+ nameTagManager.removeTag(player);
+ nameTagManager.newTag(player);
+ }
+ }
+ }
+ public Rank getRank(UUID uuid) {
+ return Rank.valueOf(config.getString(uuid.toString()));
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/ScoreboardListener.java b/src/main/java/me/night/nullvalkyrie/ui/ScoreboardListener.java
similarity index 92%
rename from src/main/java/me/night/nullvalkyrie/rank/ScoreboardListener.java
rename to src/main/java/me/night/nullvalkyrie/ui/ScoreboardListener.java
index 343dfc3..182f7e6 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/ScoreboardListener.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/ScoreboardListener.java
@@ -1,73 +1,73 @@
-package me.night.nullvalkyrie.rank;
-
-import me.night.nullvalkyrie.Main;
-import me.night.nullvalkyrie.npc.NPC;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.entity.PlayerDeathEvent;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import static me.night.nullvalkyrie.database.DatabaseManager.createUserSchema;
-
-public class ScoreboardListener implements Listener {
-
- public static RankManager rankManager;
- public static NameTagManager nameTagManager;
- private final SideBarManager sideBarManager;
- private final BelowNameManager belowNameManager;
- public ScoreboardListener(Main main) {
- nameTagManager = new NameTagManager(main);
- rankManager = new RankManager(main);
- sideBarManager = new SideBarManager(main);
- belowNameManager = new BelowNameManager();
- }
-
- @EventHandler
- public void onJoin(PlayerJoinEvent e) {
- Player player = e.getPlayer();
- if(!player.hasPlayedBefore()) {
- e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
- rankManager.setRank(player.getUniqueId(), Rank.ROOKIE);
- createUserSchema(e.getPlayer().getDisplayName());
- }
- e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1");
- nameTagManager.setNametags(player);
- nameTagManager.newTag(player);
- sideBarManager.setSideBar(player);
- sideBarManager.start(player);
- belowNameManager.setBelowName(player);
- e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!");
- if(NPC.getNPCs() == null) return;
- if(NPC.getNPCs().isEmpty()) return;
- NPC.addJoinPacket(e.getPlayer());
- }
-
- @EventHandler
- public void onQuit(PlayerQuitEvent e) {
- e.setQuitMessage(ChatColor.RED + "bozo " + e.getPlayer().getName() + " has left.");
- nameTagManager.removeTag(e.getPlayer());
- e.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
- AnimatedSideBar board = new AnimatedSideBar(e.getPlayer().getUniqueId());
- if(board.hasID()) {
- board.stop();
- }
- }
-
- @EventHandler
- public void onChat(AsyncPlayerChatEvent e) {
- e.setCancelled(true);
- Player player = e.getPlayer();
- Bukkit.broadcastMessage(rankManager.getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage());
- }
-
- //Death changing in sidebar
- @EventHandler
- public void onDeath(PlayerDeathEvent e) {
- sideBarManager.changeOnDeath(e.getEntity().getPlayer());
- }
-}
+package me.night.nullvalkyrie.ui;
+
+import me.night.nullvalkyrie.Main;
+import me.night.nullvalkyrie.npc.NPC;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+import static me.night.nullvalkyrie.database.DatabaseManager.createUserSchema;
+
+public class ScoreboardListener implements Listener {
+
+ public static RankManager rankManager;
+ public static NameTagManager nameTagManager;
+ private final SideBarManager sideBarManager;
+ private final BelowNameManager belowNameManager;
+ public ScoreboardListener(Main main) {
+ nameTagManager = new NameTagManager();
+ rankManager = new RankManager(main);
+ sideBarManager = new SideBarManager(main);
+ belowNameManager = new BelowNameManager();
+ }
+
+ @EventHandler
+ public void onJoin(PlayerJoinEvent e) {
+ Player player = e.getPlayer();
+ if(!player.hasPlayedBefore()) {
+ e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Matrix!", ChatColor.GREEN + "LOL", 20, 100, 20);
+ rankManager.setRank(player.getUniqueId(), Rank.ROOKIE);
+ createUserSchema(e.getPlayer().getDisplayName());
+ }
+ e.getPlayer().setPlayerListHeaderFooter(ChatColor.AQUA + "You are playing on " + ChatColor.GREEN + "127.0.0.1", ChatColor.GOLD + "Ranks, boosters, & more!" + ChatColor.AQUA + "127.0.0.1");
+ nameTagManager.setNametags(player);
+ nameTagManager.newTag(player);
+ sideBarManager.setSideBar(player);
+ sideBarManager.start(player);
+ belowNameManager.setBelowName(player);
+ e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!");
+ if(NPC.getNPCs() == null) return;
+ if(NPC.getNPCs().isEmpty()) return;
+ NPC.addJoinPacket(e.getPlayer());
+ }
+
+ @EventHandler
+ public void onQuit(PlayerQuitEvent e) {
+ e.setQuitMessage(ChatColor.RED + "bozo " + e.getPlayer().getName() + " has left.");
+ nameTagManager.removeTag(e.getPlayer());
+ e.getPlayer().setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
+ AnimatedSideBar board = new AnimatedSideBar(e.getPlayer().getUniqueId());
+ if(board.hasID()) {
+ board.stop();
+ }
+ }
+
+ @EventHandler
+ public void onChat(AsyncPlayerChatEvent e) {
+ e.setCancelled(true);
+ Player player = e.getPlayer();
+ Bukkit.broadcastMessage(rankManager.getRank(player.getUniqueId()).getDisplay() + " " + player.getName() + ChatColor.WHITE + ": " + e.getMessage());
+ }
+
+ //Death changing in sidebar
+ @EventHandler
+ public void onDeath(PlayerDeathEvent e) {
+ if(e.getEntity().getPlayer() == null) sideBarManager.changeOnDeath(e.getEntity().getPlayer());
+ }
+}
diff --git a/src/main/java/me/night/nullvalkyrie/rank/SideBarManager.java b/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java
similarity index 92%
rename from src/main/java/me/night/nullvalkyrie/rank/SideBarManager.java
rename to src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java
index d272271..2b187c5 100644
--- a/src/main/java/me/night/nullvalkyrie/rank/SideBarManager.java
+++ b/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java
@@ -1,107 +1,105 @@
-package me.night.nullvalkyrie.rank;
-
-import me.night.nullvalkyrie.Main;
-import me.night.nullvalkyrie.util.Util;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.*;
-import org.bukkit.scoreboard.Scoreboard;
-
-import java.util.HashMap;
-import java.util.UUID;
-
-public class SideBarManager {
- private final HashMap deaths = new HashMap<>();
- private int taskID;
- private final Main main;
-
- public SideBarManager(Main main) {
- this.main = main;
- }
-
- @SuppressWarnings("deprecation")
- public void setSideBar(Player player) {
- Scoreboard board = player.getScoreboard();
- Objective obj;
- if (board.getObjective("Vanadium") != null) {
- obj = board.getObjective("Vanadium");
- } else {
- obj = board.registerNewObjective("Vanadium", "dummy");
- }
- obj.setDisplaySlot(DisplaySlot.SIDEBAR);
- obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<");
- Score hypens = obj.getScore(ChatColor.GOLD + "=-=-=-=-=-=-=-=");
- hypens.setScore(9);
- Score name = obj.getScore(ChatColor.BLUE + "Player Name: ");
- name.setScore(8);
- Score name2 = obj.getScore(ChatColor.WHITE + player.getName());
- name2.setScore(7);
- Score space1 = obj.getScore(" ");
- space1.setScore(6);
- Score players = obj.getScore(ChatColor.LIGHT_PURPLE + "Players Online:");
- players.setScore(5);
- Score playercount = obj.getScore(ChatColor.YELLOW.toString() + Bukkit.getServer().getOnlinePlayers().size());
- playercount.setScore(4);
- Score space2 = obj.getScore(" ");
- space2.setScore(2);
- Score website = obj.getScore(ChatColor.YELLOW + "cath.js.org");
- website.setScore(1);
- Team playersOnline;
- if (board.getTeam("deathsTotal") != null) {
- playersOnline = board.getTeam("deathsTotal");
- } else playersOnline = board.registerNewTeam("deathsTotal");
- playersOnline.addEntry(ChatColor.BOLD.toString());
- playersOnline.setPrefix(ChatColor.BLUE + "Deaths: ");
- playersOnline.setSuffix(ChatColor.YELLOW + "0");
- obj.getScore(ChatColor.BOLD.toString()).setScore(3);
- player.setScoreboard(board);
- deaths.put(player.getUniqueId(), 0);
- }
-
- public void start(Player player) {
- taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
- int count = 0;
- final AnimatedSideBar board = new AnimatedSideBar(player.getUniqueId());
-
- public void animate(String str) {
- Objective objective = player.getScoreboard().getObjective("Vanadium");
- objective.setDisplaySlot(DisplaySlot.SIDEBAR);
- objective.setDisplayName(Util.color(str));
- }
-
- @Override
- public void run() {
- if (!board.hasID())
- board.setID(taskID);
- if (count == 13)
- count = 0;
- switch (count) {
- case 0 -> animate("&1&l>> &e&lVanadium&1&l <<");
- case 1 -> animate("&b&l>&1&l> &e&lVanadium &1&l<<");
- case 2 -> animate("&1&l>&b&l> &e&lVanadium &1&l<<");
- case 3 -> animate("&1&l>> &b&lV&e&lanadium&1&l <<");
- case 4 -> animate("&1&l>> &e&lV&b&la&e&lnadium&1&l <<");
- case 5 -> animate("&1&l>> &e&lVa&b&ln&e&ladium&1&l <<");
- case 6 -> animate("&1&l>> &e&lVan&b&la&e&ldium&1&l <<");
- case 7 -> animate("&1&l>> &e&lVana&b&ld&e&lium&1&l <<");
- case 8 -> animate("&1&l>> &e&lVanad&b&li&e&lum&1&l <<");
- case 9 -> animate("&1&l>> &e&lVanadi&b&lu&e&lm&1&l <<");
- case 10 -> animate("&1&l>> &e&lVanadiu&b&lm&1&l <<");
- case 11 -> animate("&1&l>> &e&lVanadium &b&l<&1&l<");
- case 12 -> {
- animate("&1&l>> &e&lVanadium &1&l<&b&l<");
- setSideBar(player);
- }
- }
- count++;
- }
- }, 0, 10);
- }
-
- public void changeOnDeath(Player player) {
- int amount = deaths.get(player.getUniqueId());
- deaths.put(player.getUniqueId(), amount++);
- player.getScoreboard().getTeam("deathsTotal").setSuffix(ChatColor.YELLOW.toString() + amount);
- }
-}
+package me.night.nullvalkyrie.ui;
+
+import me.night.nullvalkyrie.Main;
+import me.night.nullvalkyrie.util.Util;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.*;
+import org.bukkit.scoreboard.Scoreboard;
+
+import java.util.HashMap;
+import java.util.UUID;
+
+public class SideBarManager {
+ private final HashMap deaths = new HashMap<>();
+ private int taskID;
+ private final Main main;
+
+ public SideBarManager(Main main) {
+ this.main = main;
+ }
+
+ public void setSideBar(Player player) {
+ Scoreboard board = player.getScoreboard();
+ Objective obj;
+ if (board.getObjective("Vanadium") != null) {
+ obj = board.getObjective("Vanadium");
+ } else {
+ obj = board.registerNewObjective("Vanadium", Criteria.DUMMY, ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<");
+ }
+ obj.setDisplaySlot(DisplaySlot.SIDEBAR);
+ Score hypens = obj.getScore(ChatColor.GOLD + "=-=-=-=-=-=-=-=");
+ hypens.setScore(9);
+ Score name = obj.getScore(ChatColor.BLUE + "Player Name: ");
+ name.setScore(8);
+ Score name2 = obj.getScore(ChatColor.WHITE + player.getName());
+ name2.setScore(7);
+ Score space1 = obj.getScore(" ");
+ space1.setScore(6);
+ Score players = obj.getScore(ChatColor.LIGHT_PURPLE + "Players Online:");
+ players.setScore(5);
+ Score playercount = obj.getScore(ChatColor.YELLOW.toString() + Bukkit.getServer().getOnlinePlayers().size());
+ playercount.setScore(4);
+ Score space2 = obj.getScore(" ");
+ space2.setScore(2);
+ Score website = obj.getScore(ChatColor.YELLOW + "cath.js.org");
+ website.setScore(1);
+ Team playersOnline;
+ if (board.getTeam("deathsTotal") != null) {
+ playersOnline = board.getTeam("deathsTotal");
+ } else playersOnline = board.registerNewTeam("deathsTotal");
+ playersOnline.addEntry(ChatColor.BOLD.toString());
+ playersOnline.setPrefix(ChatColor.BLUE + "Deaths: ");
+ playersOnline.setSuffix(ChatColor.YELLOW + "0");
+ obj.getScore(ChatColor.BOLD.toString()).setScore(3);
+ player.setScoreboard(board);
+ deaths.put(player.getUniqueId(), 0);
+ }
+
+ public void start(Player player) {
+ taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
+ int count = 0;
+ final AnimatedSideBar board = new AnimatedSideBar(player.getUniqueId());
+
+ public void animate(String str) {
+ Objective objective = player.getScoreboard().getObjective("Vanadium");
+ objective.setDisplaySlot(DisplaySlot.SIDEBAR);
+ objective.setDisplayName(Util.color(str));
+ }
+
+ @Override
+ public void run() {
+ if (!board.hasID())
+ board.setID(taskID);
+ if (count == 13)
+ count = 0;
+ switch (count) {
+ case 0 -> animate("&1&l>> &e&lVanadium&1&l <<");
+ case 1 -> animate("&b&l>&1&l> &e&lVanadium &1&l<<");
+ case 2 -> animate("&1&l>&b&l> &e&lVanadium &1&l<<");
+ case 3 -> animate("&1&l>> &b&lV&e&lanadium&1&l <<");
+ case 4 -> animate("&1&l>> &e&lV&b&la&e&lnadium&1&l <<");
+ case 5 -> animate("&1&l>> &e&lVa&b&ln&e&ladium&1&l <<");
+ case 6 -> animate("&1&l>> &e&lVan&b&la&e&ldium&1&l <<");
+ case 7 -> animate("&1&l>> &e&lVana&b&ld&e&lium&1&l <<");
+ case 8 -> animate("&1&l>> &e&lVanad&b&li&e&lum&1&l <<");
+ case 9 -> animate("&1&l>> &e&lVanadi&b&lu&e&lm&1&l <<");
+ case 10 -> animate("&1&l>> &e&lVanadiu&b&lm&1&l <<");
+ case 11 -> animate("&1&l>> &e&lVanadium &b&l<&1&l<");
+ case 12 -> {
+ animate("&1&l>> &e&lVanadium &1&l<&b&l<");
+ setSideBar(player);
+ }
+ }
+ count++;
+ }
+ }, 0, 10);
+ }
+
+ public void changeOnDeath(Player player) {
+ int amount = deaths.get(player.getUniqueId());
+ deaths.put(player.getUniqueId(), amount++);
+ player.getScoreboard().getTeam("deathsTotal").setSuffix(ChatColor.YELLOW.toString() + amount);
+ }
+}