diff --git a/src/main/java/com/night/nullvalkyrie/Chests/MenuListener.java b/src/main/java/com/night/nullvalkyrie/Chests/MenuListener.java index 2c24c1c..9305069 100644 --- a/src/main/java/com/night/nullvalkyrie/Chests/MenuListener.java +++ b/src/main/java/com/night/nullvalkyrie/Chests/MenuListener.java @@ -32,6 +32,6 @@ public class MenuListener implements Listener { player.closeInventory(); - } + }else { return; } } } diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index d01715a..deaaaef 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -50,11 +50,15 @@ public final class Main extends JavaPlugin implements Listener { 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()); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", BarColor.RED, diff --git a/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java new file mode 100644 index 0000000..9fa8ec6 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/AnvilCommand.java @@ -0,0 +1,21 @@ +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 { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + player.openInventory(Bukkit.createInventory(player, InventoryType.ANVIL)); + } + + + return false; + } +} \ 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 ddd0c90..973c8ea 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/ArmorCommand.java @@ -1,6 +1,6 @@ package com.night.nullvalkyrie.commands; -import org.bukkit.ChatColor; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -10,40 +10,43 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; public class ArmorCommand implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - 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"); - helmetdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); - helmetdata.setUnbreakable(true); - helmet.setItemMeta(helmetdata); - player.getInventory().addItem(helmet); + 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"); + helmetdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + helmetdata.setUnbreakable(true); + helmet.setItemMeta(helmetdata); + player.getInventory().addItem(helmet); - ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); - cpdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Chestplate"); - cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); - cpdata.setUnbreakable(true); - cp.setItemMeta(cpdata); - player.getInventory().addItem(cp); + ItemStack cp = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta cpdata = (LeatherArmorMeta) cp.getItemMeta(); + cpdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Chestplate"); + cpdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + cpdata.setUnbreakable(true); + cp.setItemMeta(cpdata); + player.getInventory().addItem(cp); - ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta(); - legdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Leggings"); - legdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); - legdata.setUnbreakable(true); - leg.setItemMeta(legdata); - player.getInventory().addItem(leg); + ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta legdata = (LeatherArmorMeta) leg.getItemMeta(); + legdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Leggings"); + legdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + legdata.setUnbreakable(true); + leg.setItemMeta(legdata); + player.getInventory().addItem(leg); - ItemStack boot = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta(); - bootdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Boots"); - bootdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); - bootdata.setUnbreakable(true); - boot.setItemMeta(legdata); - player.getInventory().addItem(boot); + ItemStack boot = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta bootdata = (LeatherArmorMeta) boot.getItemMeta(); + bootdata.setDisplayName(net.md_5.bungee.api.ChatColor.of("#ff23ff") + "Angeles Boots"); + bootdata.setColor(org.bukkit.Color.fromRGB(2,2,58)); + bootdata.setUnbreakable(true); + boot.setItemMeta(legdata); + player.getInventory().addItem(boot); + } return false; diff --git a/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java b/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java new file mode 100644 index 0000000..fdd9918 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/ArmorTab.java @@ -0,0 +1,32 @@ + +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/CraftCommand.java b/src/main/java/com/night/nullvalkyrie/commands/CraftCommand.java new file mode 100644 index 0000000..da4d239 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/CraftCommand.java @@ -0,0 +1,19 @@ +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 { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + player.openWorkbench(null, true); + } + + + return false; + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java b/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java new file mode 100644 index 0000000..8575c1f --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/EnchantingCommand.java @@ -0,0 +1,21 @@ +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 EnchantingCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + player.openEnchanting(null, true); + } + + + return false; + } +} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 59985af..7dc2875 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -21,4 +21,13 @@ commands: rank: description: "Set rank of players" hologram: - description: "Spawn a hologram" \ No newline at end of file + 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