From 21975d62b19a43340f7e3f9b2930f1f683c9ef58 Mon Sep 17 00:00:00 2001 From: night0721 Date: Thu, 7 Jul 2022 23:22:56 +0100 Subject: [PATCH] Command Handler --- .../java/com/night/nullvalkyrie/Main.java | 23 ++-------- .../nullvalkyrie/commands/AnvilCommand.java | 24 +++++++--- .../nullvalkyrie/commands/ArmorCommand.java | 35 +++++++++++--- .../night/nullvalkyrie/commands/ArmorTab.java | 32 ------------- .../night/nullvalkyrie/commands/Command.java | 46 +++++++++++++++++++ .../nullvalkyrie/commands/CraftCommand.java | 25 +++++++--- .../commands/EnchantingCommand.java | 29 ++++++++---- .../nullvalkyrie/commands/GunCommand.java | 26 ++++++++--- .../commands/HologramCommand.java | 23 +++++++--- .../nullvalkyrie/commands/MenuCommand.java | 24 +++++++--- .../nullvalkyrie/commands/MessageCommand.java | 21 +++++++-- .../nullvalkyrie/commands/RankCommand.java | 29 ++++++++---- .../nullvalkyrie/commands/TestCommand.java | 26 ++++++++--- .../nullvalkyrie/commands/VanishCommand.java | 20 +++++--- src/main/resources/plugin.yml | 28 +---------- 15 files changed, 262 insertions(+), 149 deletions(-) delete mode 100644 src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java create mode 100644 src/main/java/com/night/nullvalkyrie/commands/Command.java diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index deaaaef..feaca86 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -44,21 +44,8 @@ public final class Main extends JavaPlugin implements Listener { public SideBarManager getSideBarManager() { return sideBarManager; } @Override public void onEnable() { - // Plugin startup logic - System.out.println("PREPARING TO DESTROY HYPIXEL"); - - getCommand("test").setExecutor(new TestCommand()); - getCommand("vanish").setExecutor(new VanishCommand()); - getCommand("armor").setExecutor(new ArmorCommand()); - getCommand("armor").setTabCompleter(new ArmorTab()); - getCommand("gun").setExecutor(new GunCommand()); - getCommand("msg").setExecutor(new MessageCommand()); - getCommand("menu").setExecutor(new MenuCommand()); - getCommand("rank").setExecutor(new RankCommand(this)); - getCommand("hologram").setExecutor(new HologramCommand()); - getCommand("craft").setExecutor(new CraftCommand()); - getCommand("anvil").setExecutor(new AnvilCommand()); - getCommand("enchant").setExecutor(new EnchantingCommand()); + new VanishCommand();new TestCommand();new GunCommand();new AnvilCommand();new ArmorCommand();new MenuCommand();new RankCommand(this); + new MessageCommand();new HologramCommand();new CraftCommand();new EnchantingCommand(); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", BarColor.RED, @@ -105,7 +92,7 @@ public final class Main extends JavaPlugin implements Listener { public void onJoin(PlayerJoinEvent e) { e.setJoinMessage(rankManager.getRank(e.getPlayer().getUniqueId()).getDisplay() + " " + e.getPlayer().getName() + ChatColor.WHITE + " joined the server!"); - e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Operation Valkyrie!", ChatColor.GREEN + "LOL", 20, 100, 20); + e.getPlayer().sendTitle(ChatColor.RED +"Welcome to Apache!", ChatColor.GREEN + "LOL", 20, 100, 20); e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("ยง1NOT ENOUGH MANNER")); bossbar.addPlayer(e.getPlayer()); @@ -127,8 +114,8 @@ public final class Main extends JavaPlugin implements Listener { @EventHandler public void onPing(ServerListPingEvent e) { e.setMaxPlayers(8964); - String s = centerText("Operation Valkyrie\n", 45); - String s2 = centerText("Support 1.18 & 1.8.9",45); + String s = centerText("Apache\n", 45); + String s2 = centerText("Support 1.18 & 1.8.9",15); e.setMotd(ChatColor.AQUA.toString() + ChatColor.BOLD + s + ChatColor.GOLD + ChatColor.BOLD + s2); try { e.setServerIcon(Bukkit.loadServerIcon(new File("nuke.png"))); diff --git a/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java index 9fa8ec6..7744dad 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java @@ -1,21 +1,33 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; -public class AnvilCommand implements CommandExecutor { +import java.util.List; + +public class AnvilCommand extends Command { + + public AnvilCommand() { + super( + "anvil", + new String[]{"av"}, + "Open anvil", + "" + ); + } + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; player.openInventory(Bukkit.createInventory(player, InventoryType.ANVIL)); } + } - - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } \ No newline at end of file diff --git a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java index 973c8ea..de0d02e 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java @@ -2,17 +2,29 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.StringUtil; -public class ArmorCommand implements CommandExecutor { +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ArmorCommand extends Command { + + public ArmorCommand() { + super( + "armor", + new String[]{}, + "Give you a set of armor", + "" + ); + } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); @@ -47,8 +59,19 @@ public class ArmorCommand implements CommandExecutor { boot.setItemMeta(legdata); player.getInventory().addItem(boot); } + } - - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + if(args.length == 1) { + return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>()); + } else if(args.length == 2) { + List names = new ArrayList<>(); + for(Player player: Bukkit.getOnlinePlayers()) { + names.add(player.getName()); + } + return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>()); + } + return new ArrayList<>(); } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java b/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java deleted file mode 100644 index fdd9918..0000000 --- a/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java +++ /dev/null @@ -1,32 +0,0 @@ - -package com.night.nullvalkyrie.commands; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ArmorTab implements TabCompleter { - - @Override - public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if(args.length == 1) { - return StringUtil.copyPartialMatches(args[0], Arrays.asList("angeles", "widow"), new ArrayList<>()); - } else if(args.length == 2) { - List names = new ArrayList<>(); - for(Player player: Bukkit.getOnlinePlayers()) { - names.add(player.getName()); - } - return StringUtil.copyPartialMatches(args[1], names, new ArrayList<>()); - } - - - return new ArrayList<>(); - } -} diff --git a/src/main/java/com/night/nullvalkyrie/commands/Command.java b/src/main/java/com/night/nullvalkyrie/commands/Command.java new file mode 100644 index 0000000..513f2c0 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/Command.java @@ -0,0 +1,46 @@ +package com.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; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.List; + +public abstract class Command extends BukkitCommand { + + public Command(String command, String[] aliases, String description, String permission) { + super(command); + this.setAliases(Arrays.asList(aliases)); + this.setDescription(description); + this.setPermission(permission); + this.setPermission(ChatColor.RED + "You must have" + permission + "in order to use this command"); + + try { + Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap"); + field.setAccessible(true); + CommandMap map = (CommandMap) field.get(Bukkit.getServer()); + map.register(command, this); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + + } + + @Override + public boolean execute(CommandSender sender, String commandLabel, String[] args) { + onCommand(sender, args); + return false; + } + + @Override + 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/com/night/nullvalkyrie/commands/CraftCommand.java b/src/main/java/com/night/nullvalkyrie/commands/CraftCommand.java index da4d239..29d2612 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/CraftCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/CraftCommand.java @@ -1,19 +1,32 @@ package com.night.nullvalkyrie.commands; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class CraftCommand implements CommandExecutor { +import java.util.List; + +public class CraftCommand extends Command { + + public CraftCommand() { + super( + "craft", + new String[]{"ct", "crafting", "craftingtable"}, + "Open crafting table", + "" + ); + } + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; player.openWorkbench(null, true); } + } - - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java b/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java index 8575c1f..a1060eb 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java @@ -1,21 +1,30 @@ package com.night.nullvalkyrie.commands; - import org.bukkit.Bukkit; - import org.bukkit.command.Command; - import org.bukkit.command.CommandExecutor; - import org.bukkit.command.CommandSender; - import org.bukkit.entity.Player; - import org.bukkit.event.inventory.InventoryType; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class EnchantingCommand extends Command { + public EnchantingCommand() { + super( + "enchant", + new String[]{"et", "enchanting", "enchantingtable"}, + "Open enchanting table", + "" + ); + } -public class EnchantingCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; player.openEnchanting(null, true); } + } - - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } \ No newline at end of file diff --git a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java index d6774a2..5c66b57 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/GunCommand.java @@ -2,19 +2,29 @@ package com.night.nullvalkyrie.commands; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; import java.util.Arrays; +import java.util.List; + +public class GunCommand extends Command { + + public GunCommand() { + super( + "gun", + new String[]{}, + "Give you a gun", + "" + + ); + } + -public class GunCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { Player player = (Player) sender; ItemStack hoe = new ItemStack(Material.DIAMOND_HOE); ItemMeta hoedata = hoe.getItemMeta(); @@ -23,6 +33,10 @@ public class GunCommand implements CommandExecutor { hoedata.setLore(Arrays.asList(ChatColor.GOLD + "Shoot Snowball!")); hoe.setItemMeta(hoedata); player.getInventory().addItem(hoe); - return false; + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java b/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java index 4437062..3d6344b 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java @@ -2,16 +2,24 @@ package com.night.nullvalkyrie.commands; import org.bukkit.ChatColor; import org.bukkit.Location; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -public class HologramCommand implements CommandExecutor { +import java.util.List; + +public class HologramCommand extends Command { + public HologramCommand() { + super( + "hologram", + new String[]{}, + "Spawn a hologram", + "" + ); + } + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; String[] ar = new String[]{ @@ -30,7 +38,10 @@ public class HologramCommand implements CommandExecutor { stand.setCustomName(line); } } + } - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java b/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java index 71fd57c..0dc7df3 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/MenuCommand.java @@ -3,8 +3,6 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -12,12 +10,22 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.Arrays; +import java.util.List; -public class MenuCommand implements CommandExecutor { +public class MenuCommand extends Command { public static Inventory inv = Bukkit.createInventory(null, 45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu"); - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public MenuCommand() { + super( + "menu", + new String[]{"m"}, + "Open the menu", + "" + ); + } + + @Override + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; inv = Bukkit.createInventory(player,45, ChatColor.DARK_BLUE.toString() + ChatColor.BOLD + "Valkyrie Menu"); @@ -58,6 +66,10 @@ public class MenuCommand implements CommandExecutor { player.openInventory(inv); } - return false; + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java b/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java index 6cd23bd..696e079 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/MessageCommand.java @@ -2,15 +2,23 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class MessageCommand implements CommandExecutor { +import java.util.List; + +public class MessageCommand extends Command { + public MessageCommand() { + super( + "message", + new String[]{"msg"}, + "Send message to someone", + "" + ); + } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; if (args.length >= 2) { @@ -29,7 +37,10 @@ public class MessageCommand implements CommandExecutor { player.sendMessage(ChatColor.RED + "Invalid parameter, use /msg "); } } + } - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java b/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java index 6b8bc2e..8dee19b 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java @@ -7,26 +7,34 @@ import com.night.nullvalkyrie.RankSys.Rank; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; //92.0.69.141:25565 -public class RankCommand implements CommandExecutor { +public class RankCommand extends Command { private Main main; public RankCommand(Main main) { + super( + "rank", + new String[]{}, + "Set rank of players", + "" + ); this.main = main; } private Cache cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build(); + + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; - if(!cooldown.asMap().containsKey(player.getUniqueId())) {if(player.isOp()) { + 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]); @@ -37,8 +45,9 @@ public class RankCommand implements CommandExecutor { if(target.isOnline()) { target.getPlayer().sendMessage(ChatColor.GREEN + player.getName() + " set your rank to " + rank.getDisplay()); } - return true; + return; } + } player.sendMessage(ChatColor.RED + "Invalid Rank, please specify a valid rank, ROOKIE, SPECIAL, ADMIN, OWNER"); } else { @@ -50,12 +59,16 @@ public class RankCommand implements CommandExecutor { } 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 { long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis(); player.sendMessage(ChatColor.RED + "You are on a " + TimeUnit.MILLISECONDS.toSeconds(distance) + " seconds cooldown to use the command again"); } } - return false; + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/TestCommand.java b/src/main/java/com/night/nullvalkyrie/commands/TestCommand.java index 84b6b2a..dfb90f8 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/TestCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/TestCommand.java @@ -1,22 +1,34 @@ package com.night.nullvalkyrie.commands; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; + import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class TestCommand implements CommandExecutor { +import java.util.List; +public class TestCommand extends Command { + public TestCommand() { + super( + "test", + new String[]{}, + "Test", + "" + ); + } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { if(sender instanceof Player) { if(args.length == 1) { if(args[0].equalsIgnoreCase("hello")) { - Player player = ((Player) sender); - Command.broadcastCommandMessage(player,player.getAddress().getHostString()); + Player player = (Player) sender; + player.sendMessage(player.getAddress().getHostString()); } } } - return false; + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java index 698cd13..0f0fc58 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/VanishCommand.java @@ -2,8 +2,6 @@ package com.night.nullvalkyrie.commands; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,10 +9,18 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -public class VanishCommand implements CommandExecutor { +public class VanishCommand extends Command { private List vanished = new ArrayList<>(); + public VanishCommand() { + super( + "vanish", + new String[]{}, + "Turn yourself into invisible", + "" + ); + } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender, String[] args) { Player player = (Player) sender; if(sender instanceof Player) { if(vanished.contains(player.getUniqueId())) { @@ -31,8 +37,10 @@ public class VanishCommand implements CommandExecutor { player.sendMessage(ChatColor.GREEN + "You are now vanished"); } } + } - - return false; + @Override + public List onTabComplete(CommandSender sender, String[] args) { + return null; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7dc2875..2a3b645 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,30 +4,4 @@ main: com.night.nullvalkyrie.Main api-version: 1.18 authors: [ NightKaly, Leocthl ] description: Null Valkyrie -website: https://github.com/night0721/nullvalkyrie -commands: - test: - description: "Test" - vanish: - description: "Turn yourself into invisible" - armor: - description: "Give you a set of armor" - gun: - description: "Give you a gun" - msg: - description: "Send message to someone" - menu: - description: "Open the menu" - rank: - description: "Set rank of players" - hologram: - description: "Spawn a hologram" - craft: - aliases: ["ct", "crafting", "craftingtable"] - description: "Open crafting table" - anvil: - aliases: [ "av", "anvil" ] - description: "Open anvil" - enchant: - aliases: [ "et", "enchanting", "enchantingtable"] - description: "Open enchanting table" \ No newline at end of file +website: https://github.com/night0721/nullvalkyrie \ No newline at end of file