From 6437c34e53d605f9feb4ae6988f38163baff7b1f Mon Sep 17 00:00:00 2001 From: Legit4K <44619264+Legit4K@users.noreply.github.com> Date: Wed, 25 Aug 2021 16:16:50 +0100 Subject: [PATCH 1/4] . --- .../java/net/nuggetmc/tplus/command/commands/BotCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java index 7933548..89c273e 100644 --- a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java +++ b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java @@ -140,6 +140,7 @@ 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 = "info", desc = "Information about loaded bots.", From 3224b5a9f6f8f0c9e60ad6e4d3a408ebbf578611 Mon Sep 17 00:00:00 2001 From: Legit4K <44619264+Legit4K@users.noreply.github.com> Date: Wed, 25 Aug 2021 17:33:21 +0100 Subject: [PATCH 2/4] Add /bot armor command --- .../tplus/command/commands/BotCommand.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java index 89c273e..f0d5a9a 100644 --- a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java +++ b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java @@ -140,6 +140,39 @@ 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 = " (example: leather)" + ) + public void armor(CommandSender sender, List args) { + String armor = args.get(0); + + ItemStack[] armorLeather = new ItemStack[4]; + armorLeather[0] = new ItemStack(Material.LEATHER_BOOTS, 1); + armorLeather[1] = new ItemStack(Material.LEATHER_LEGGINGS, 1); + armorLeather[2] = new ItemStack(Material.LEATHER_CHESTPLATE, 1); + armorLeather[3] = new ItemStack(Material.LEATHER_HELMET, 1); + + ItemStack[] armorGold = new ItemStack[4]; + armorGold[0] = new ItemStack(Material.GOLDEN_BOOTS, 1); + armorGold[1] = new ItemStack(Material.GOLDEN_LEGGINGS, 1); + armorGold[2] = new ItemStack(Material.GOLDEN_CHESTPLATE, 1); + armorGold[3] = new ItemStack(Material.GOLDEN_HELMET, 1); + + switch(armor) { + case leather: + armor = armorLeather; + break; + case gold: + armor = armorGold; + break; + default: + armor = armorGold; + } + + manager.fetch().forEach(bot bot. setArmorContents(armor)) + } @Command( name = "info", From be9fd43dd4a420fdc47e7df929ad1e9b3bae38f3 Mon Sep 17 00:00:00 2001 From: Legit4K <44619264+Legit4K@users.noreply.github.com> Date: Wed, 25 Aug 2021 22:23:14 +0100 Subject: [PATCH 3/4] finalize everything --- .../tplus/command/commands/BotCommand.java | 82 ++++++++++++++----- 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java index f0d5a9a..620695b 100644 --- a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java +++ b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java @@ -143,35 +143,79 @@ public class BotCommand extends CommandInstance { @Command( name = "armor", desc = "Gives all bots an armor set.", - usage = " (example: leather)" + usage = "" ) public void armor(CommandSender sender, List args) { - String armor = args.get(0); + String tier = args.get(0).toLowerCase(); - ItemStack[] armorLeather = new ItemStack[4]; - armorLeather[0] = new ItemStack(Material.LEATHER_BOOTS, 1); - armorLeather[1] = new ItemStack(Material.LEATHER_LEGGINGS, 1); - armorLeather[2] = new ItemStack(Material.LEATHER_CHESTPLATE, 1); - armorLeather[3] = new ItemStack(Material.LEATHER_HELMET, 1); - - ItemStack[] armorGold = new ItemStack[4]; - armorGold[0] = new ItemStack(Material.GOLDEN_BOOTS, 1); - armorGold[1] = new ItemStack(Material.GOLDEN_LEGGINGS, 1); - armorGold[2] = new ItemStack(Material.GOLDEN_CHESTPLATE, 1); - armorGold[3] = new ItemStack(Material.GOLDEN_HELMET, 1); - - switch(armor) { - case leather: + 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 gold: + 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: - armor = armorGold; + sender.sendMessage(ChatColor.RED + tier + ChatColor.RESET + " is not valid!"); + sender.sendMessage("Available Tiers: " + ChatColor.AQUA + "leather, chain, iron, gold, diamond, netherite"); + return; } - manager.fetch().forEach(bot bot. setArmorContents(armor)) + 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( From 5d0d5319ddce813a7fae673d2314d9059714693e Mon Sep 17 00:00:00 2001 From: Legit4K <44619264+Legit4K@users.noreply.github.com> Date: Wed, 25 Aug 2021 22:51:34 +0100 Subject: [PATCH 4/4] fix missing words... --- .../java/net/nuggetmc/tplus/command/commands/BotCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java index 620695b..e49397e 100644 --- a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java +++ b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java @@ -206,7 +206,7 @@ public class BotCommand extends CommandInstance { armor = armorNetherite; break; default: - sender.sendMessage(ChatColor.RED + tier + ChatColor.RESET + " is not valid!"); + 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; }