From ebbfad3339a9a1218eb08d4006d26104ce3261e7 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 10 Dec 2018 22:59:41 +0800 Subject: [PATCH] 1.0.0-SNAPSHOT-U119 + Added the boss new command command --- TODO | 1 - .../epicbosses/commands/boss/BossNewCmd.java | 52 ++++++++++++++++++- .../com/songoda/epicbosses/utils/Message.java | 7 +-- pom.xml | 2 +- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index c0379e7..98c4490 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ -> Add the Custom Skill Editing GUIs --> Add the new Command aspect (via command) -> Add the new Message aspect (via command) -> Add the new Skill aspect (via command) -> Add the DropTable Main Editing GUI (Will have buttons for DropType and Rewards) diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/commands/boss/BossNewCmd.java b/plugin-modules/Core/src/com/songoda/epicbosses/commands/boss/BossNewCmd.java index acae567..4b34f50 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/commands/boss/BossNewCmd.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/commands/boss/BossNewCmd.java @@ -4,12 +4,17 @@ import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.droptable.DropTable; import com.songoda.epicbosses.managers.BossDropTableManager; +import com.songoda.epicbosses.managers.files.CommandsFileManager; import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.managers.files.MessagesFileManager; import com.songoda.epicbosses.utils.Message; import com.songoda.epicbosses.utils.Permission; import com.songoda.epicbosses.utils.command.SubCommand; import org.bukkit.command.CommandSender; +import java.util.ArrayList; +import java.util.List; + /** * @author Charles Cullen * @version 1.0.0 @@ -24,12 +29,16 @@ public class BossNewCmd extends SubCommand { private DropTableFileManager dropTableFileManager; private BossDropTableManager bossDropTableManager; + private MessagesFileManager messagesFileManager; + private CommandsFileManager commandsFileManager; public BossNewCmd(CustomBosses plugin) { super("new"); this.dropTableFileManager = plugin.getDropTableFileManager(); this.bossDropTableManager = plugin.getBossDropTableManager(); + this.messagesFileManager = plugin.getBossMessagesFileManager(); + this.commandsFileManager = plugin.getBossCommandFileManager(); } @Override @@ -40,12 +49,53 @@ public class BossNewCmd extends SubCommand { } if(args.length >= 4 && args[1].equalsIgnoreCase("command")) { + String nameInput = args[2]; + if(this.commandsFileManager.getCommands(nameInput) != null) { + Message.Boss_New_AlreadyExists.msg(sender, "Command"); + return; + } + + int length = args.length; + List commands = new ArrayList<>(); + StringBuilder current = new StringBuilder(); + + for(int i = 4; i < length; i++) { + String arg = args[i]; + + if(arg.contains("||")) { + String[] split = arg.split("||"); + + current.append(split[0]); + commands.add(current.toString()); + + if(split.length >= 2) { + current = new StringBuilder(split[1]); + } else { + current = new StringBuilder(); + } + + continue; + } + + current.append(arg); + } + + commands.add(current.toString()); + this.commandsFileManager.addNewCommand(nameInput, commands); + this.commandsFileManager.save(); + + Message.Boss_New_Command.msg(sender, nameInput); return; } if(args.length >= 4 && args[1].equalsIgnoreCase("message")) { String nameInput = args[2]; + + if(this.commandsFileManager.getCommands(nameInput) != null) { + Message.Boss_New_AlreadyExists.msg(sender, "Message"); + return; + } } if(args.length == 4 && args[1].equalsIgnoreCase("droptable")) { @@ -54,7 +104,7 @@ public class BossNewCmd extends SubCommand { boolean validType = false; if(this.dropTableFileManager.getDropTable(nameInput) != null) { - Message.Boss_New_DropTableAlreadyExists.msg(sender); + Message.Boss_New_AlreadyExists.msg(sender, "DropTable"); return; } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java index 790092e..9a8ad6a 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java @@ -81,8 +81,8 @@ public enum Message { "&b/boss giveegg [name] [player] (amount) &8» &7Used to be given a " + "spawn item of the boss.\n" + "&b/boss list &8» &7Shows all the list of current boss entities.\n" + - "&b/boss new skill [name] [type] [mode] &8» &7Used to create a new skill section.\n" + - "&b/boss new droptable [name] [type] &8» &7Used to create a new drop table.\n" + + "&b/boss new skill [name] [type] [mode] &8» &7Create a new skill section.\n" + + "&b/boss new droptable [name] [type] &8» &7Create a new drop table section.\n" + "&7\n" + "&7Use /boss help 4 to view the next page.\n" + "&8&m----*-----------------------------------*----"), @@ -140,9 +140,10 @@ public enum Message { Boss_New_CreateArgumentsDropTable("&b&lEpicBosses &8» &7Create a new droptable with the command &f/boss new droptable [name] [type]&7."), Boss_New_CreateArgumentsMessage("&b&lEpicBosses &8» &7Create a new message with the command &f/boss new message [name] [message(s)]. \n&7&oUse &f|| &7&oto reference a new line."), Boss_New_CreateArgumentsCommand("&b&lEpicBosses &8» &7Create a new command with the command &f/boss new command [name] [command(s)]. \n&7&oUse &f|| &7&oto reference a new line."), - Boss_New_DropTableAlreadyExists("&c&l(!) &cThe specified DropTable name already exists. Please try another name."), + Boss_New_AlreadyExists("&c&l(!) &cThe specified {0} name already exists. Please try another name."), Boss_New_InvalidDropTableType("&c&l(!) &cThe specified DropTable type is invalid. Please use &fGive, Drop, Spray&c."), Boss_New_DropTable("&b&lEpicBosses &8» &7You have created a new drop table with the name &f{0}&7 and type &f{1}&7."), + Boss_New_Command("&b&lEpicBosses &8» &7You have created a new command with the name &f{0}&7."), Boss_New_SomethingWentWrong("&c&l(!) &cSomething went wrong while trying to create a new &f{0}&c."), Boss_Reload_NoPermission("&c&l(!) &cYou do not have access to this command."), diff --git a/pom.xml b/pom.xml index 877eee3..2c2b7db 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 1.0.0-U118 + 1.0.0-U119 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev