.env fix
This commit is contained in:
parent
4da943e385
commit
a7b7db3db2
12 changed files with 36 additions and 38 deletions
|
@ -14,18 +14,16 @@ import me.night.nullvalkyrie.database.DatabaseManager;
|
|||
import org.bukkit.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
|
||||
public static Dotenv env;
|
||||
@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();
|
||||
env = Dotenv.configure().directory("E:\\Files\\SB\\plugins\\NullValkyrie").filename(".env").load();
|
||||
new CommandManager(this);
|
||||
Bukkit.getPluginManager().registerEvents(new ServerEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new MenuListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(this), this);
|
||||
|
@ -34,6 +32,6 @@ public final class Main extends JavaPlugin {
|
|||
Bukkit.getPluginManager().registerEvents(new NPCEvents(), this);
|
||||
new DiscordClientManager();
|
||||
new DatabaseManager(this);
|
||||
NPC.loadNPC(CustomItemManager.loadConfig("npcs.yml"));
|
||||
NPCManager.reloadNPC();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
package me.night.nullvalkyrie.commands;
|
||||
|
||||
import me.night.nullvalkyrie.Main;
|
||||
import me.night.nullvalkyrie.npc.NPC;
|
||||
import me.night.nullvalkyrie.npc.NPCManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BetaCommand extends Command {
|
||||
private Main main;
|
||||
|
||||
public BetaCommand(Main main) {
|
||||
public BetaCommand() {
|
||||
super("beta", new String[]{"b", "npc"}, "Beta", "");
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
NPC.createNPC(player, "&a&lNK");
|
||||
NPCManager.createNPC(player, "&a&lNK");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -3,11 +3,7 @@ package me.night.nullvalkyrie.commands;
|
|||
import me.night.nullvalkyrie.Main;
|
||||
|
||||
public class CommandManager {
|
||||
private final Main main;
|
||||
public CommandManager(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
public void register() {
|
||||
new VanishCommand();
|
||||
new TestCommand();
|
||||
new AnvilCommand();
|
||||
|
@ -21,7 +17,7 @@ public class CommandManager {
|
|||
new RankCommand();
|
||||
new UtilCommand();
|
||||
new ShopCommand();
|
||||
new BetaCommand(main);
|
||||
new BetaCommand();
|
||||
new MinerCommand(main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,11 @@ public class DatabaseManager {
|
|||
connect();
|
||||
}
|
||||
public void connect() {
|
||||
// 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);
|
||||
// }
|
||||
try (MongoClient client = MongoClients.create(Main.env.get("MONGODB_URI"))) {
|
||||
|
||||
} 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");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package me.night.nullvalkyrie.discord;
|
||||
import me.night.nullvalkyrie.Main;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
|
@ -12,7 +13,7 @@ public class DiscordClientManager {
|
|||
register();
|
||||
}
|
||||
public void register() {
|
||||
JDABuilder builder = JDABuilder.createDefault("OTk3ODczMzgyNjM0ODM2MDQ5.Gd9Fdh.GEOleI-1znVeHwaAef54nXl2ovlSmC3hQX-qQI");
|
||||
JDABuilder builder = JDABuilder.createDefault(Main.env.get("DISCORD_TOKEN"));
|
||||
builder.setActivity(Activity.streaming("cath.exe", "https://www.youtube.com/watch?v=YSKDu1gKntY"));
|
||||
try {
|
||||
jda = builder.build();
|
||||
|
|
|
@ -4,24 +4,25 @@ import org.bukkit.NamespacedKey;
|
|||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CustomEnchantment extends Enchantment {
|
||||
private final String name;
|
||||
private final int maxlvl;
|
||||
private final int max;
|
||||
public CustomEnchantment(String namespace, String name, int lvl) {
|
||||
super(NamespacedKey.minecraft(namespace));
|
||||
this.name = name;
|
||||
this.maxlvl = lvl;
|
||||
this.max = lvl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return maxlvl;
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +31,7 @@ public class CustomEnchantment extends Enchantment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public @NotNull EnchantmentTarget getItemTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -45,12 +46,12 @@ public class CustomEnchantment extends Enchantment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean conflictsWith(Enchantment other) {
|
||||
public boolean conflictsWith(@NotNull Enchantment other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnchantItem(ItemStack item) {
|
||||
public boolean canEnchantItem(@NotNull ItemStack item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class NPCEvents implements Listener {
|
|||
}
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
NPC.getNPCs().stream().forEach(npc -> {
|
||||
NPCManager.getNPCs().forEach(npc -> {
|
||||
Location location = npc.getBukkitEntity().getLocation();
|
||||
location.setDirection(e.getPlayer().getLocation().subtract(location).toVector());
|
||||
float yaw = location.getYaw();
|
||||
|
|
|
@ -32,13 +32,15 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NPC {
|
||||
public class NPCManager {
|
||||
private static final List<EntityPlayer> NPCs = new ArrayList<>();
|
||||
|
||||
public static List<EntityPlayer> getNPCs() {
|
||||
return NPCs;
|
||||
}
|
||||
|
||||
public static void reloadNPC() {
|
||||
loadNPC(CustomItemManager.loadConfig("npcs.yml"));
|
||||
}
|
||||
public static void createNPC(Player player, String name) { //name must be less than 16 characters including color codes **
|
||||
EntityPlayer sp = ((CraftPlayer) player).getHandle();
|
||||
MinecraftServer server = sp.c;
|
|
@ -36,7 +36,7 @@ public class PacketHandler extends ChannelDuplexHandler {
|
|||
hand.setAccessible(true);
|
||||
if (!hand.get(data).toString().equals("MAIN_HAND")) { return; }
|
||||
//Right Click
|
||||
for (EntityPlayer npcs : NPC.getNPCs()) {
|
||||
for (EntityPlayer npcs : NPCManager.getNPCs()) {
|
||||
if (npcs.ae() == entityID && sneak) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package me.night.nullvalkyrie.ui;
|
||||
|
||||
import me.night.nullvalkyrie.Main;
|
||||
import me.night.nullvalkyrie.npc.NPC;
|
||||
import me.night.nullvalkyrie.npc.NPCManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -42,9 +42,9 @@ public class ScoreboardListener implements Listener {
|
|||
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());
|
||||
if(NPCManager.getNPCs() == null) return;
|
||||
if(NPCManager.getNPCs().isEmpty()) return;
|
||||
NPCManager.addJoinPacket(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -4,6 +4,7 @@ import static me.night.nullvalkyrie.items.CustomItemManager.updateYamlFilesToPlu
|
|||
|
||||
public class FileManager {
|
||||
public FileManager() {
|
||||
updateYamlFilesToPlugin(".env");
|
||||
updateYamlFilesToPlugin("shop.yml");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,3 +9,5 @@ depend: [ProtocolLib]
|
|||
permissions:
|
||||
nv.command.use:
|
||||
default: true
|
||||
libraries:
|
||||
- "io.github.cdimascio:dotenv-java:2.3.1"
|
||||
|
|
Loading…
Reference in a new issue