diff --git a/src/main/java/me/night/nullvalkyrie/Main.java b/src/main/java/me/night/nullvalkyrie/Main.java index ac91bef..2f1a081 100644 --- a/src/main/java/me/night/nullvalkyrie/Main.java +++ b/src/main/java/me/night/nullvalkyrie/Main.java @@ -14,11 +14,9 @@ import me.night.nullvalkyrie.commands.*; 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; public static MongoDatabase database; - @Override public void onEnable() { EnchantmentManager.register(); diff --git a/src/main/java/me/night/nullvalkyrie/commands/AnvilCommand.java b/src/main/java/me/night/nullvalkyrie/commands/AnvilCommand.java index 5c41c42..750697b 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/AnvilCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/AnvilCommand.java @@ -1,25 +1,37 @@ package me.night.nullvalkyrie.commands; -import org.bukkit.Bukkit; +import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.inventory.Containers; import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; import java.util.List; public class AnvilCommand extends Command { public AnvilCommand() { - super("anvil", new String[]{"av"}, "Open anvil", ""); + super( + "anvil", + new String[]{"av"}, + "Open anvil", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - Inventory av = Bukkit.createInventory(null, InventoryType.ANVIL, "AV"); - player.openInventory(av); + if (sender instanceof Player) { + Player player = (Player) sender; + CraftPlayer craftPlayer = (CraftPlayer) player; +// EntityPlayer entityPlayer = craftPlayer.getHandle(); +// int id = 0; +// PacketPlayOutOpenWindow OpenWindow = new PacketPlayOutOpenWindow(id, Containers.h, CraftChatMessage.fromStringOrNull("Test")); +// PlayerConnection playerConnection = entityPlayer.b; +// playerConnection.a(OpenWindow); } } diff --git a/src/main/java/me/night/nullvalkyrie/commands/ArmorCommand.java b/src/main/java/me/night/nullvalkyrie/commands/ArmorCommand.java index 220d625..afb3fa6 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/ArmorCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/ArmorCommand.java @@ -15,12 +15,18 @@ import java.util.List; public class ArmorCommand extends Command { public ArmorCommand() { - super("armor", new String[]{}, "Give you a set of armor", ""); + super( + "armor", + new String[]{}, + "Give you a set of armor", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { + Player player = (Player) sender; ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); LeatherArmorMeta helmetdata = (LeatherArmorMeta) helmet.getItemMeta(); helmetdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Helmet"); diff --git a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java index 453ec37..48423d6 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java @@ -13,10 +13,9 @@ public class BetaCommand extends Command { @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { } } - @Override public List onTabComplete(CommandSender sender, String[] args) { return null; diff --git a/src/main/java/me/night/nullvalkyrie/commands/Command.java b/src/main/java/me/night/nullvalkyrie/commands/Command.java index 328a61d..00c225c 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/Command.java +++ b/src/main/java/me/night/nullvalkyrie/commands/Command.java @@ -1,6 +1,7 @@ package me.night.nullvalkyrie.commands; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; @@ -38,8 +39,6 @@ public abstract class Command extends BukkitCommand { public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { return onTabComplete(sender, args); } - public abstract void onCommand(CommandSender sender, String[] args); - public abstract List onTabComplete(CommandSender sender, String[] args); } diff --git a/src/main/java/me/night/nullvalkyrie/commands/CraftCommand.java b/src/main/java/me/night/nullvalkyrie/commands/CraftCommand.java index 1d5dbfc..3bbddca 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/CraftCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/CraftCommand.java @@ -8,12 +8,18 @@ import java.util.List; public class CraftCommand extends Command { public CraftCommand() { - super("craft", new String[]{"ct", "crafting", "craftingtable"}, "Open crafting table", ""); + super( + "craft", + new String[]{"ct", "crafting", "craftingtable"}, + "Open crafting table", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { + Player player = (Player) sender; player.openWorkbench(null, true); } } diff --git a/src/main/java/me/night/nullvalkyrie/commands/EnchantingCommand.java b/src/main/java/me/night/nullvalkyrie/commands/EnchantingCommand.java index 7d7d24b..c9d65ac 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/EnchantingCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/EnchantingCommand.java @@ -7,12 +7,18 @@ import java.util.List; public class EnchantingCommand extends Command { public EnchantingCommand() { - super("enchant", new String[]{"et", "enchanting", "enchantingtable"}, "Open enchanting table", ""); + super( + "enchant", + new String[]{"et", "enchanting", "enchantingtable"}, + "Open enchanting table", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { + Player player = (Player) sender; player.openEnchanting(player.getLocation(), true); } } diff --git a/src/main/java/me/night/nullvalkyrie/commands/HologramCommand.java b/src/main/java/me/night/nullvalkyrie/commands/HologramCommand.java index 3b4ace8..8269af5 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/HologramCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/HologramCommand.java @@ -10,13 +10,23 @@ import java.util.List; public class HologramCommand extends Command { public HologramCommand() { - super("hologram", new String[]{}, "Spawn a hologram", ""); + super( + "hologram", + new String[]{}, + "Spawn a hologram", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - String[] ar = new String[]{ChatColor.AQUA + "Hi", ChatColor.DARK_PURPLE + "What", ChatColor.GOLD + "Hello World"}; + if (sender instanceof Player) { + Player player = (Player) sender; + String[] ar = new String[]{ + ChatColor.AQUA + "Hi", + ChatColor.DARK_PURPLE + "What", + ChatColor.GOLD + "Hello World" + }; Location location = player.getLocation(); for (String line : ar) { ArmorStand stand = location.getWorld().spawn(location.subtract(0, 0.3, 0), ArmorStand.class, armorStand -> { diff --git a/src/main/java/me/night/nullvalkyrie/commands/MessageCommand.java b/src/main/java/me/night/nullvalkyrie/commands/MessageCommand.java index 9344559..8801e47 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/MessageCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/MessageCommand.java @@ -11,12 +11,18 @@ import java.util.List; public class MessageCommand extends Command { public MessageCommand() { - super("message", new String[]{"msg"}, "Send message to someone", ""); + super( + "message", + new String[]{"msg"}, + "Send message to someone", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { + Player player = (Player) sender; if (args.length >= 2) { if (Bukkit.getPlayerExact(args[0]) != null) { Player target = Bukkit.getPlayerExact(args[0]); diff --git a/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java b/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java index 36cfd58..419051b 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java @@ -14,7 +14,12 @@ import static me.night.nullvalkyrie.miners.CryptoMiner.generate; public class MinerCommand extends Command { public MinerCommand() { - super("miner", new String[]{"m", "miners"}, "Miner list", ""); + super( + "miner", + new String[]{"m", "miners"}, + "Miner list", + "" + ); } @Override diff --git a/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java b/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java index 2805337..1920075 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/RankCommand.java @@ -15,7 +15,12 @@ import java.util.List; public class RankCommand extends Command { public RankCommand() { - super("rank", new String[]{}, "Set rank of players", "nv.rank.add"); + super( + "rank", + new String[]{}, + "Set rank of players", + "nv.rank.add" + ); } diff --git a/src/main/java/me/night/nullvalkyrie/commands/TestCommand.java b/src/main/java/me/night/nullvalkyrie/commands/TestCommand.java index 8665dc0..ad0b693 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/TestCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/TestCommand.java @@ -7,7 +7,12 @@ import java.util.List; public class TestCommand extends Command { public TestCommand() { - super("test", new String[]{}, "Test", ""); + super( + "test", + new String[]{}, + "Test", + "" + ); } @Override diff --git a/src/main/java/me/night/nullvalkyrie/commands/VanishCommand.java b/src/main/java/me/night/nullvalkyrie/commands/VanishCommand.java index c0fb3ce..9e8b852 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/VanishCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/VanishCommand.java @@ -13,12 +13,18 @@ public class VanishCommand extends Command { private final List vanished = new ArrayList<>(); public VanishCommand() { - super("vanish", new String[]{}, "Turn yourself into invisible", ""); + super( + "vanish", + new String[]{}, + "Turn yourself into invisible", + "" + ); } @Override public void onCommand(CommandSender sender, String[] args) { - if (sender instanceof Player player) { + if (sender instanceof Player) { + Player player = (Player) sender; if (vanished.contains(player.getUniqueId())) { vanished.remove(player.getUniqueId()); for (Player target : Bukkit.getOnlinePlayers()) { diff --git a/src/main/java/me/night/nullvalkyrie/discord/DiscordClientManager.java b/src/main/java/me/night/nullvalkyrie/discord/DiscordClientManager.java index 0916bc7..41b2de6 100644 --- a/src/main/java/me/night/nullvalkyrie/discord/DiscordClientManager.java +++ b/src/main/java/me/night/nullvalkyrie/discord/DiscordClientManager.java @@ -1,5 +1,4 @@ package me.night.nullvalkyrie.discord; - import me.night.nullvalkyrie.Main; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder; @@ -10,11 +9,9 @@ import javax.security.auth.login.LoginException; public class DiscordClientManager { private JDA jda; - public DiscordClientManager() { register(); } - public void register() { JDABuilder builder = JDABuilder.createDefault(Main.env.get("DISCORD_TOKEN")); builder.setActivity(Activity.streaming("cath.exe", "https://www.youtube.com/watch?v=YSKDu1gKntY")); diff --git a/src/main/java/me/night/nullvalkyrie/enchantments/CustomEnchantment.java b/src/main/java/me/night/nullvalkyrie/enchantments/CustomEnchantment.java index 45333d0..ca60e8f 100644 --- a/src/main/java/me/night/nullvalkyrie/enchantments/CustomEnchantment.java +++ b/src/main/java/me/night/nullvalkyrie/enchantments/CustomEnchantment.java @@ -9,7 +9,6 @@ import org.jetbrains.annotations.NotNull; public class CustomEnchantment extends Enchantment { private final String name; private final int max; - public CustomEnchantment(String namespace, String name, int lvl) { super(NamespacedKey.minecraft(namespace)); this.name = name; diff --git a/src/main/java/me/night/nullvalkyrie/enchantments/EnchantmentManager.java b/src/main/java/me/night/nullvalkyrie/enchantments/EnchantmentManager.java index 28164b1..7199c99 100644 --- a/src/main/java/me/night/nullvalkyrie/enchantments/EnchantmentManager.java +++ b/src/main/java/me/night/nullvalkyrie/enchantments/EnchantmentManager.java @@ -6,25 +6,24 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class EnchantmentManager { public static final Enchantment ThunderBolt = new CustomEnchantment("thunderbolt", "ThunderBolt", 5); public static final Enchantment SmeltingTouch = new CustomEnchantment("smelting-touch", "Smelting Touch", 1); - public static void register() { List enchants = new ArrayList<>(); enchants.add(ThunderBolt); enchants.add(SmeltingTouch); List registeredList = new ArrayList<>(); for (Enchantment enchant : enchants) { - registeredList.add(Arrays.stream(Enchantment.values()).toList().contains(enchant)); + registeredList.add(Arrays.stream(Enchantment.values()).collect(Collectors.toList()).contains(enchant)); } for (int counter = 0; counter < registeredList.size(); counter++) { if (!registeredList.get(counter)) registerEnchantment(enchants.get(counter)); } } - public static void registerEnchantment(Enchantment en) { try { try { diff --git a/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java b/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java index 6379036..0e99fca 100644 --- a/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java +++ b/src/main/java/me/night/nullvalkyrie/ui/AnimatedSideBar.java @@ -9,19 +9,15 @@ import java.util.UUID; public class AnimatedSideBar { private static final Map Tasks = new HashMap<>(); private final UUID uuid; - public AnimatedSideBar(UUID uuid) { this.uuid = uuid; } - public void setID(int id) { Tasks.put(uuid, id); } - public boolean hasID() { return Tasks.containsKey(uuid); } - public void stop() { Bukkit.getScheduler().cancelTask(Tasks.get(uuid)); } diff --git a/src/main/java/me/night/nullvalkyrie/ui/Rank.java b/src/main/java/me/night/nullvalkyrie/ui/Rank.java index 2b8eca4..4faba34 100644 --- a/src/main/java/me/night/nullvalkyrie/ui/Rank.java +++ b/src/main/java/me/night/nullvalkyrie/ui/Rank.java @@ -3,7 +3,10 @@ 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 + ""); + OWNER(ChatColor.DARK_RED + ""), + ADMIN(ChatColor.RED + ""), + SPECIAL(ChatColor.GOLD + ""), + ROOKIE(ChatColor.DARK_GREEN + ""); private final String display; diff --git a/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java b/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java index 3a8f27a..0fd74d8 100644 --- a/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java +++ b/src/main/java/me/night/nullvalkyrie/ui/SideBarManager.java @@ -25,8 +25,7 @@ public class SideBarManager { 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 <<"); + 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); @@ -59,13 +58,11 @@ public class SideBarManager { board = new AnimatedSideBar(player.getUniqueId()); taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(main, new Runnable() { int count = 0; - public void animate(String str) { Scoreboard board = player.getScoreboard(); Objective objective; if (board.getObjective("Vanadium") != null) objective = board.getObjective("Vanadium"); - else - objective = board.registerNewObjective("Vanadium", Criteria.DUMMY, ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<"); + else objective = board.registerNewObjective("Vanadium", Criteria.DUMMY, ChatColor.AQUA.toString() + ChatColor.BOLD + ">> Vanadium <<"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(Util.color(str)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b04de34..0c91cbd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ api-version: 1.18 authors: [ NightKaly, Leocthl ] description: Null Valkyrie website: https://github.com/night0721/nullvalkyrie -depend: [ ProtocolLib ] +depend: [ProtocolLib] permissions: nv.command.use: default: true