ArchonCrates with Custom Prizes

Discussion in 'Spigot Plugin Development' started by bmac20, May 29, 2016.

  1. So I have this command for my server that is working fine:
    Code (Text):
            if (cmd.getName().equalsIgnoreCase("health")) {

                ItemStack is = new ItemStack(Material.ENCHANTED_BOOK, 1);
                ItemMeta im = is.getItemMeta();
                im.setDisplayName(ChatColor.YELLOW + "Enchanted Book");
                EnchantmentStorageMeta eMeta = (EnchantmentStorageMeta) is.getItemMeta();
                is.setItemMeta(im);
                Health healthObject = new Health();

                PlayerInventory pi = p.getInventory();
                EnchantmentAPI.getEnchantments(healthObject.addToItem(is, 1));
                pi.addItem(is);
    Does anyone know how I would add this item to ArchonCrates so that people can have a chance at winning this?
    It's basically a book, and when you put it on armor, it gives you extra hearts.
     
  2. Can that plugin execute commands? I haven't used it. If it can you should just be able to make it execute /health as the player or something :p
     
  3. Yea it can, but I don't know how to give it to the player that entered the crate.
     
  4. Well I don't know either, I make plugins, I don't configure them. This should probably be in Spigot Plugin Help tbh
     
  5. That's what I had it in at first.
    @BrettplayMC
    @symvizan
     
  6. If it can execute commands it should have some sort of placeholders created that would replace for example the player name. If it's that you should be able to have it execute /health %player%
     
  7. I guess a better question would be how to put the book in the crate. When players left click the crate, it brings up a list of prizes and their chance, so I don't know how to add this book into the crate. Because the ids would be the same.
     
  8. Have you tried adding the item to the prizes list via config?
     
  9. Yes. This is my command so far:
    Code (Text):
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                return true;
            }

            Player p = (Player) sender;

            if (cmd.getName().equalsIgnoreCase("health")) {

                ItemStack is = new ItemStack(Material.ENCHANTED_BOOK, 1);
                ItemMeta im = is.getItemMeta();
                im.setDisplayName(ChatColor.YELLOW + "Enchanted Book");
                EnchantmentStorageMeta eMeta = (EnchantmentStorageMeta) is.getItemMeta();
                is.setItemMeta(im);
                Health healthObject = new Health();

                EnchantmentAPI.getEnchantments(healthObject.addToItem(is, 1));

                Player target = Bukkit.getServer().getPlayer(args[0]);

                if (target == null) {
                    p.sendMessage(ChatColor.RED + "You must specify a player.");
                    return true;

                } else {

                    target.getInventory().addItem(is);
                }

            }

            return false;

        }
    It's giving me an error here:
    Code (Text):
    Player target = Bukkit.getServer().getPlayer(args[0]);
     
  10. No i mean literately adding that item into the config for ArchonCrates. Also you are not checking if args.length is 1 so you will get a error
     
  11. I figured out how to make the command. When I type /health bmac20, it gives bmac20 the book. But in the ArchonCrates config I have "health <player>" I don't need slashes btw.