diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreForgeMain.java b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreForgeMain.java index f276588..adb8a56 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreForgeMain.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/mod/FoxCoreForgeMain.java @@ -34,13 +34,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import org.apache.logging.log4j.Logger; -@Mod(modid = "foxcoreforge", name = "FoxCoreForge", version = FoxCoreMain.VERSION, acceptableRemoteVersions = "*") +@Mod(modid = "foxcorecui", name = "FoxCoreCUI", version = FoxCoreMain.VERSION, acceptableRemoteVersions = "*") public class FoxCoreForgeMain { - @Mod.Instance("foxcoreforge") + @Mod.Instance("foxcorecui") public static FoxCoreForgeMain instance; - @SidedProxy(modId = "foxcoreforge", clientSide = "net.foxdenstudio.sponge.foxcore.mod.ClientProxy", serverSide = "net.foxdenstudio.sponge.foxcore.mod.CommonProxy") + @SidedProxy(modId = "foxcorecui", clientSide = "net.foxdenstudio.sponge.foxcore.mod.ClientProxy", serverSide = "net.foxdenstudio.sponge.foxcore.mod.CommonProxy") public static CommonProxy proxy; public static Logger logger; diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandAdd.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandAdd.java index d705b94..d92dafb 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandAdd.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandAdd.java @@ -66,7 +66,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm if (result.isSuccess()) { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.GREEN).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.GREEN).build()); } else { source.sendMessage(result.getMessage().get()); } @@ -76,7 +76,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } else { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.RED).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.RED).build()); } else { source.sendMessage(result.getMessage().get()); } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java index 78b0c6f..e4a3931 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandPosition.java @@ -54,7 +54,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm if (result.isSuccess()) { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.GREEN).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.GREEN).build()); } else { source.sendMessage(result.getMessage().get()); } @@ -64,7 +64,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } else { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.RED).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.RED).build()); } else { source.sendMessage(result.getMessage().get()); } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandSubtract.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandSubtract.java index 3839081..0e8e340 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandSubtract.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandSubtract.java @@ -77,7 +77,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm if (result.isSuccess()) { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.GREEN).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.GREEN).build()); } else { source.sendMessage(result.getMessage().get()); } @@ -87,7 +87,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } else { if (result.getMessage().isPresent()) { if (!FCHelper.hasColor(result.getMessage().get())) { - source.sendMessage(result.getMessage().get().builder().color(TextColors.RED).build()); + source.sendMessage(result.getMessage().get().toBuilder().color(TextColors.RED).build()); } else { source.sendMessage(result.getMessage().get()); } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java index f18e3c6..504ff51 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/CommandTest.java @@ -36,10 +36,12 @@ import org.spongepowered.api.text.format.TextColors; import java.util.List; +import java.util.Map; import java.util.Optional; public class CommandTest implements CommandCallable { + /* public CommandResult process(CommandSource source, String arguments) throws CommandException { if (!testPermission(source)) { source.sendMessage(Text.of(TextColors.RED, "You don't have permission to use this command!")); @@ -56,10 +58,11 @@ public CommandResult process(CommandSource source, String arguments) throws Comm source.sendMessage(builder.build()); return CommandResult.empty(); } + */ @Override public List getSuggestions(CommandSource source, String arguments) throws CommandException { - AdvCmdParse.ParseResult parse = AdvCmdParse.builder().arguments(arguments).autoCloseQuotes(true).limit(3).parse2(); + AdvCmdParse.ParseResult parse = AdvCmdParse.builder().arguments(arguments).autoCloseQuotes(true).limit(2).parse2(); Text.Builder builder = Text.builder(); builder.append(Text.of(TextColors.GOLD, "-----------------------------\n")); builder.append(Text.of(TextColors.GOLD, "Args: \"", TextColors.RESET, arguments, TextColors.GOLD, "\"\n")); @@ -91,7 +94,7 @@ public Text getUsage(CommandSource source) { return Text.of("test [mystery args]..."); } - /* + @Override public CommandResult process(CommandSource source, String arguments) throws CommandException { if (!testPermission(source)) { @@ -111,5 +114,5 @@ public CommandResult process(CommandSource source, String arguments) throws Comm } source.sendMessage(builder.build()); return CommandResult.empty(); - }*/ + } } diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java index 7642b28..f353771 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/FCCommandDispatcher.java @@ -204,7 +204,7 @@ public CommandResult process(CommandSource source, String inputArguments) throws Text.of(TextColors.GOLD, optCommand.get().getPrimaryAlias()), Text.of(TextColors.GOLD, "\" Help"), Text.of(TextColors.GREEN, "----------\n")); - source.sendMessage(builder.append(helpText.orElse(Text.of("Usage: " + dispatcherPrefix + " ").builder().append(command.getUsage(source)).build())).build()); + source.sendMessage(builder.append(helpText.orElse(Text.of("Usage: " + dispatcherPrefix + " ").toBuilder().append(command.getUsage(source)).build())).build()); return CommandResult.empty(); } else { source.sendMessage(this.getHelp(source).get()); @@ -224,8 +224,8 @@ public CommandResult process(CommandSource source, String inputArguments) throws } catch (CommandException e) { Text text = e.getText(); if (text == null) text = Text.of("There was an error processing command: " + args[0]); - source.sendMessage(text.builder().color(TextColors.RED).build()); - source.sendMessage(Text.of("Usage: " + dispatcherPrefix + " ").builder() + source.sendMessage(text.toBuilder().color(TextColors.RED).build()); + source.sendMessage(Text.of("Usage: " + dispatcherPrefix + " ").toBuilder() .append(command.getUsage(source)).color(TextColors.RED).build()); return CommandResult.empty(); } @@ -283,7 +283,7 @@ public Optional getHelp(CommandSource source) { if (this.commands.isEmpty()) { return Optional.empty(); } - Text.Builder build = Text.of(TextColors.GREEN, "Available commands:\n").builder(); + Text.Builder build = Text.of(TextColors.GREEN, "Available commands:\n").toBuilder(); for (Iterator it = filterCommandMappings(source).iterator(); it.hasNext(); ) { CommandMapping mapping = it.next(); diff --git a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParse.java b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParse.java index cd7e4b5..cac9287 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParse.java +++ b/src/main/java/net/foxdenstudio/sponge/foxcore/plugin/command/util/AdvCmdParse.java @@ -243,11 +243,6 @@ public ParseResult parse() throws CommandException { } } - if (!finalString.isEmpty()) - - { - finalList.add(finalString); - } // Converts final argument list to an array. parseResult.args = finalList.toArray(new String[finalList.size()]); @@ -286,7 +281,6 @@ public ParseResult parse2() throws CommandException { // Matcher for identifying arguments and flags. Matcher matcher = pattern.matcher(arguments); boolean lastIsCurrent = !(arguments.length() == 0) && (inQuote || !arguments.substring(arguments.length() - 1).matches("[\"' ]")); - System.out.println(lastIsCurrent); // Iterate through matches while (matcher.find()) { @@ -388,6 +382,7 @@ public ParseResult parse2() throws CommandException { if (!lastIsCurrent && (parseResult.currentElement == null || parseResult.currentElement.type != CurrentElement.ElementType.COMMENT)) { parseResult.currentElement = new CurrentElement(CurrentElement.ElementType.ARGUMENT, "", argsList.size(), ""); } + System.out.println(argsList); // This part converts the argument list to the final argument array. // A number of arguments are copied to a new list less than or equal to the limit. @@ -404,6 +399,11 @@ public ParseResult parse2() throws CommandException { } } } + if (!finalString.isEmpty()) { + finalList.add(finalString); + } + + System.out.println(finalString); if (parseResult.currentElement != null && parseResult.currentElement.type == CurrentElement.ElementType.ARGUMENT && parseResult.currentElement.index >= limit) parseResult.currentElement = new CurrentElement(CurrentElement.ElementType.FINAL, finalString + (lastIsCurrent ? "" : " "), finalList.size() - 1, "");