Merge pull request #20 from Legit4K/patch-3

Introduce /bot armor command
This commit is contained in:
Chris
2021-08-25 17:28:52 -05:00
committed by GitHub

View File

@@ -140,6 +140,84 @@ public class BotCommand extends CommandInstance {
sender.sendMessage("Successfully set the default item to " + ChatColor.YELLOW + item.getType() + ChatColor.RESET + " for all current bots.");
}
@Command(
name = "armor",
desc = "Gives all bots an armor set.",
usage = "<armor tier>"
)
public void armor(CommandSender sender, List<String> args) {
String tier = args.get(0).toLowerCase();
ItemStack[] armorLeather = new ItemStack[4];
armorLeather[0] = new ItemStack(Material.LEATHER_BOOTS);
armorLeather[1] = new ItemStack(Material.LEATHER_LEGGINGS);
armorLeather[2] = new ItemStack(Material.LEATHER_CHESTPLATE);
armorLeather[3] = new ItemStack(Material.LEATHER_HELMET);
ItemStack[] armorChain = new ItemStack[4];
armorChain[0] = new ItemStack(Material.CHAINMAIL_BOOTS);
armorChain[1] = new ItemStack(Material.CHAINMAIL_LEGGINGS);
armorChain[2] = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
armorChain[3] = new ItemStack(Material.CHAINMAIL_HELMET);
ItemStack[] armorGold = new ItemStack[4];
armorGold[0] = new ItemStack(Material.GOLDEN_BOOTS);
armorGold[1] = new ItemStack(Material.GOLDEN_LEGGINGS);
armorGold[2] = new ItemStack(Material.GOLDEN_CHESTPLATE);
armorGold[3] = new ItemStack(Material.GOLDEN_HELMET);
ItemStack[] armorIron = new ItemStack[4];
armorIron[0] = new ItemStack(Material.IRON_BOOTS);
armorIron[1] = new ItemStack(Material.IRON_LEGGINGS);
armorIron[2] = new ItemStack(Material.IRON_CHESTPLATE);
armorIron[3] = new ItemStack(Material.IRON_HELMET);
ItemStack[] armorDiamond = new ItemStack[4];
armorDiamond[0] = new ItemStack(Material.DIAMOND_BOOTS);
armorDiamond[1] = new ItemStack(Material.DIAMOND_LEGGINGS);
armorDiamond[2] = new ItemStack(Material.DIAMOND_CHESTPLATE);
armorDiamond[3] = new ItemStack(Material.DIAMOND_HELMET);
ItemStack[] armorNetherite = new ItemStack[4];
armorNetherite[0] = new ItemStack(Material.NETHERITE_BOOTS);
armorNetherite[1] = new ItemStack(Material.NETHERITE_LEGGINGS);
armorNetherite[2] = new ItemStack(Material.NETHERITE_CHESTPLATE);
armorNetherite[3] = new ItemStack(Material.NETHERITE_HELMET);
ItemStack[] armor;
switch(tier) {
case "leather":
armor = armorLeather;
break;
case "chain":
armor = armorChain;
break;
case "gold":
armor = armorGold;
break;
case "iron":
armor = armorIron;
break;
case "diamond":
armor = armorDiamond;
break;
case "netherite":
armor = armorNetherite;
break;
default:
sender.sendMessage(ChatColor.RED + tier + ChatColor.RESET + " is not a valid tier!");
sender.sendMessage("Available Tiers: " + ChatColor.AQUA + "leather, chain, iron, gold, diamond, netherite");
return;
}
manager.fetch().forEach(bot -> {
bot.getBukkitEntity().getInventory().setArmorContents(armor);
bot.getBukkitEntity().updateInventory();
});
sender.sendMessage("Successfully set the armor tier to " + ChatColor.GREEN + tier + ChatColor.RESET + " for all current bots.");
}
@Command(
name = "info",
desc = "Information about loaded bots.",