Dotenv doesnt work and renaming
This commit is contained in:
parent
f3ccf080ea
commit
a40fba2753
17 changed files with 429 additions and 412 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -111,3 +111,4 @@ buildNumber.properties
|
||||||
|
|
||||||
# Common working directory
|
# Common working directory
|
||||||
run/
|
run/
|
||||||
|
.env
|
5
pom.xml
5
pom.xml
|
@ -101,5 +101,10 @@
|
||||||
<version>4.7.0</version>
|
<version>4.7.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.cdimascio</groupId>
|
||||||
|
<artifactId>dotenv-java</artifactId>
|
||||||
|
<version>2.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,73 +1,39 @@
|
||||||
package me.night.nullvalkyrie;
|
package me.night.nullvalkyrie;
|
||||||
|
|
||||||
|
import io.github.cdimascio.dotenv.Dotenv;
|
||||||
import me.night.nullvalkyrie.chests.MenuListener;
|
import me.night.nullvalkyrie.chests.MenuListener;
|
||||||
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
||||||
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
|
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
|
||||||
import me.night.nullvalkyrie.events.CustomItemEvents;
|
import me.night.nullvalkyrie.events.*;
|
||||||
import me.night.nullvalkyrie.events.DamageEffect;
|
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.items.CustomItemManager;
|
||||||
import me.night.nullvalkyrie.npc.ClickNPC;
|
import me.night.nullvalkyrie.npc.*;
|
||||||
import me.night.nullvalkyrie.npc.NPC;
|
import me.night.nullvalkyrie.ui.ScoreboardListener;
|
||||||
import me.night.nullvalkyrie.npc.PacketInjector;
|
import me.night.nullvalkyrie.util.*;
|
||||||
import me.night.nullvalkyrie.rank.ScoreboardListener;
|
|
||||||
import me.night.nullvalkyrie.util.FileManager;
|
|
||||||
import me.night.nullvalkyrie.util.Util;
|
|
||||||
import me.night.nullvalkyrie.commands.*;
|
import me.night.nullvalkyrie.commands.*;
|
||||||
import me.night.nullvalkyrie.database.DatabaseManager;
|
import me.night.nullvalkyrie.database.DatabaseManager;
|
||||||
import org.bukkit.*;
|
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;
|
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
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getConfig().options().copyDefaults();
|
getConfig().options().copyDefaults();
|
||||||
saveDefaultConfig();
|
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();
|
EnchantmentManager.register();
|
||||||
new CustomItemManager(this);
|
new CustomItemManager(this);
|
||||||
new FileManager();
|
new FileManager();
|
||||||
new CommandManager(this).register();
|
new CommandManager(this).register();
|
||||||
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
|
Bukkit.getPluginManager().registerEvents(new ServerEvents(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
|
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this);
|
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new CustomItemEvents(this), this);
|
Bukkit.getPluginManager().registerEvents(new CustomItemEvents(this), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new DamageEffect(this), this);
|
Bukkit.getPluginManager().registerEvents(new DamageEffectEvents(this), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ClickNPC(), this);
|
Bukkit.getPluginManager().registerEvents(new NPCEvents(), this);
|
||||||
//Bukkit.getPluginManager().registerEvents(new GameEvent(this), this);
|
|
||||||
new DiscordClientManager();
|
new DiscordClientManager();
|
||||||
new DatabaseManager();
|
new DatabaseManager(this);
|
||||||
NPC.loadNPC(CustomItemManager.loadConfig("npcs.yml"));
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.ui.Rank;
|
||||||
import me.night.nullvalkyrie.rank.Rank;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -16,7 +15,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
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 {
|
public class RankCommand extends Command {
|
||||||
|
|
||||||
|
@ -37,7 +36,10 @@ public class RankCommand extends Command {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (!cooldown.asMap().containsKey(player.getUniqueId())) {
|
if (!cooldown.asMap().containsKey(player.getUniqueId())) {
|
||||||
if (player.isOp()) {
|
if (!player.isOp()) {
|
||||||
|
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
|
if (Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) {
|
||||||
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
|
||||||
|
@ -59,9 +61,6 @@ public class RankCommand extends Command {
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
player.sendMessage(ChatColor.RED + "Invalid parameter, use /rank <Player> <Rank>");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "You must be server operator to use this command");
|
|
||||||
}
|
|
||||||
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
|
cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000);
|
||||||
} else {
|
} else {
|
||||||
long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis();
|
long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package me.night.nullvalkyrie.database;
|
||||||
import com.mongodb.MongoException;
|
import com.mongodb.MongoException;
|
||||||
import com.mongodb.client.*;
|
import com.mongodb.client.*;
|
||||||
import com.mongodb.client.model.Filters;
|
import com.mongodb.client.model.Filters;
|
||||||
|
import me.night.nullvalkyrie.Main;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
|
|
||||||
|
@ -10,15 +11,18 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public class DatabaseManager {
|
public class DatabaseManager {
|
||||||
private static MongoCollection<Document> users;
|
private static MongoCollection<Document> users;
|
||||||
public DatabaseManager() {
|
private Main main;
|
||||||
|
public DatabaseManager(Main main) {
|
||||||
|
this.main = main;
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
public void connect() {
|
public void connect() {
|
||||||
try (MongoClient client = MongoClients.create("mongodb+srv://cath_exe:gaeismypassion@cath-exe.iolb7.mongodb.net/NullValkyrie")) {
|
// 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);
|
// } 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");
|
MongoClient client = MongoClients.create("mongodb+srv://cath_exe:gaeismypassion@cath-exe.iolb7.mongodb.net/NullValkyrie");
|
||||||
MongoDatabase database = client.getDatabase("NullValkyrie");
|
MongoDatabase database = client.getDatabase("NullValkyrie");
|
||||||
users = database.getCollection("users");
|
users = database.getCollection("users");
|
||||||
|
|
|
@ -17,10 +17,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class DamageEffect implements Listener {
|
public class DamageEffectEvents implements Listener {
|
||||||
private final Main main;
|
private final Main main;
|
||||||
|
|
||||||
public DamageEffect(Main main) {
|
public DamageEffectEvents(Main main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class DamageEffect implements Listener {
|
||||||
ticksLeft--;
|
ticksLeft--;
|
||||||
indicators.put(stand, ticksLeft);
|
indicators.put(stand, ticksLeft);
|
||||||
}
|
}
|
||||||
stands.removeAll(removal);
|
removal.forEach(stands::remove);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(main, 0L, 1L);
|
}.runTaskTimer(main, 0L, 1L);
|
||||||
}
|
}
|
42
src/main/java/me/night/nullvalkyrie/events/ServerEvents.java
Normal file
42
src/main/java/me/night/nullvalkyrie/events/ServerEvents.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
34
src/main/java/me/night/nullvalkyrie/npc/NPCEvents.java
Normal file
34
src/main/java/me/night/nullvalkyrie/npc/NPCEvents.java
Normal file
|
@ -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));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AnimatedSideBar {
|
public class AnimatedSideBar {
|
||||||
private static Map<UUID, Integer> Tasks = new HashMap<>();
|
private static final Map<UUID, Integer> Tasks = new HashMap<>();
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
public AnimatedSideBar(UUID uuid) {
|
public AnimatedSideBar(UUID uuid) {
|
||||||
|
@ -17,9 +17,7 @@ public class AnimatedSideBar {
|
||||||
Tasks.put(uuid, id);
|
Tasks.put(uuid, id);
|
||||||
}
|
}
|
||||||
public boolean hasID() {
|
public boolean hasID() {
|
||||||
if (Tasks.containsKey(uuid))
|
return Tasks.containsKey(uuid);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
public void stop() {
|
public void stop() {
|
||||||
Bukkit.getScheduler().cancelTask(Tasks.get(uuid));
|
Bukkit.getScheduler().cancelTask(Tasks.get(uuid));
|
|
@ -1,7 +1,8 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Criteria;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
@ -9,9 +10,8 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||||
public class BelowNameManager {
|
public class BelowNameManager {
|
||||||
public void setBelowName(Player player) {
|
public void setBelowName(Player player) {
|
||||||
Scoreboard board = player.getScoreboard();
|
Scoreboard board = player.getScoreboard();
|
||||||
Objective obj = board.registerNewObjective("HealthBar", "health");
|
Objective obj = board.registerNewObjective("HealthBar", Criteria.HEALTH, ChatColor.RED + "❤");
|
||||||
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
obj.setDisplayName(ChatColor.RED + "❤");
|
|
||||||
player.setScoreboard(board);
|
player.setScoreboard(board);
|
||||||
player.setHealth(player.getHealth());
|
player.setHealth(player.getHealth());
|
||||||
}
|
}
|
|
@ -1,23 +1,13 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.*;
|
||||||
import org.bukkit.scoreboard.Objective;
|
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
|
||||||
import org.bukkit.scoreboard.Team;
|
|
||||||
|
|
||||||
public class NameTagManager {
|
public class NameTagManager {
|
||||||
private Main main;
|
|
||||||
|
|
||||||
public NameTagManager(Main main) {
|
|
||||||
this.main = main;
|
|
||||||
}
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void setNametags(Player player) {
|
public void setNametags(Player player) {
|
||||||
Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
Scoreboard newScoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
Objective obj = newScoreboard.registerNewObjective("TabList", "dummy");
|
Objective obj = newScoreboard.registerNewObjective("TabList", Criteria.DUMMY, "");
|
||||||
obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
|
obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
|
||||||
player.setScoreboard(newScoreboard);
|
player.setScoreboard(newScoreboard);
|
||||||
for (Rank rank : Rank.values()) {
|
for (Rank rank : Rank.values()) {
|
20
src/main/java/me/night/nullvalkyrie/ui/Rank.java
Normal file
20
src/main/java/me/night/nullvalkyrie/ui/Rank.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
|
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 final String display;
|
||||||
|
|
||||||
|
Rank(String display) {
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplay() {
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -9,16 +9,12 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static me.night.nullvalkyrie.rank.ScoreboardListener.nameTagManager;
|
import static me.night.nullvalkyrie.ui.ScoreboardListener.nameTagManager;
|
||||||
|
|
||||||
public class RankManager {
|
public class RankManager {
|
||||||
private File file;
|
private final File file;
|
||||||
private YamlConfiguration config;
|
private final YamlConfiguration config;
|
||||||
|
|
||||||
private Main main;
|
|
||||||
|
|
||||||
public RankManager(Main main) {
|
public RankManager(Main main) {
|
||||||
this.main = main;
|
|
||||||
if(!main.getDataFolder().exists()) {
|
if(!main.getDataFolder().exists()) {
|
||||||
main.getDataFolder().mkdir();
|
main.getDataFolder().mkdir();
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import me.night.nullvalkyrie.npc.NPC;
|
import me.night.nullvalkyrie.npc.NPC;
|
||||||
|
@ -21,7 +21,7 @@ public class ScoreboardListener implements Listener {
|
||||||
private final SideBarManager sideBarManager;
|
private final SideBarManager sideBarManager;
|
||||||
private final BelowNameManager belowNameManager;
|
private final BelowNameManager belowNameManager;
|
||||||
public ScoreboardListener(Main main) {
|
public ScoreboardListener(Main main) {
|
||||||
nameTagManager = new NameTagManager(main);
|
nameTagManager = new NameTagManager();
|
||||||
rankManager = new RankManager(main);
|
rankManager = new RankManager(main);
|
||||||
sideBarManager = new SideBarManager(main);
|
sideBarManager = new SideBarManager(main);
|
||||||
belowNameManager = new BelowNameManager();
|
belowNameManager = new BelowNameManager();
|
||||||
|
@ -68,6 +68,6 @@ public class ScoreboardListener implements Listener {
|
||||||
//Death changing in sidebar
|
//Death changing in sidebar
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDeath(PlayerDeathEvent e) {
|
public void onDeath(PlayerDeathEvent e) {
|
||||||
sideBarManager.changeOnDeath(e.getEntity().getPlayer());
|
if(e.getEntity().getPlayer() == null) sideBarManager.changeOnDeath(e.getEntity().getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.rank;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import me.night.nullvalkyrie.util.Util;
|
import me.night.nullvalkyrie.util.Util;
|
||||||
|
@ -20,17 +20,15 @@ public class SideBarManager {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void setSideBar(Player player) {
|
public void setSideBar(Player player) {
|
||||||
Scoreboard board = player.getScoreboard();
|
Scoreboard board = player.getScoreboard();
|
||||||
Objective obj;
|
Objective obj;
|
||||||
if (board.getObjective("Vanadium") != null) {
|
if (board.getObjective("Vanadium") != null) {
|
||||||
obj = board.getObjective("Vanadium");
|
obj = board.getObjective("Vanadium");
|
||||||
} else {
|
} else {
|
||||||
obj = board.registerNewObjective("Vanadium", "dummy");
|
obj = board.registerNewObjective("Vanadium", Criteria.DUMMY, ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<");
|
||||||
}
|
}
|
||||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
obj.setDisplayName(ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<");
|
|
||||||
Score hypens = obj.getScore(ChatColor.GOLD + "=-=-=-=-=-=-=-=");
|
Score hypens = obj.getScore(ChatColor.GOLD + "=-=-=-=-=-=-=-=");
|
||||||
hypens.setScore(9);
|
hypens.setScore(9);
|
||||||
Score name = obj.getScore(ChatColor.BLUE + "Player Name: ");
|
Score name = obj.getScore(ChatColor.BLUE + "Player Name: ");
|
Loading…
Reference in a new issue