Skip to content

Releases: 21Joakim/Jockie-Utils

Jockie Utils 1.42 [JDA v4 only]

01 Aug 12:39
41a8ce7
Compare
Choose a tag to compare
  • Changes

    • Options now use primitive default values (for primitive data types) when the value is null (just like arguments)
    • Provided options are now stored by the name (main trigger) of the option instead of the alias used, this means you can no longer know which alias was used but it is more convenient as you do not have to check all of the aliases to find out if the option was provided.
  • Bug fixes

    • Fixed a bug which caused the automatic creation of options with aliases to error
    • Fixed a bug which caused the command parser to error if -- was provided at the end of the command

Jockie Utils 1.41 [JDA v4 only]

11 Jul 06:41
db83775
Compare
Choose a tag to compare
  • Features

    • Added the ability to add and remove option prefixes with CommandParserImpl#addOptionPrefix and #removeOptionPrefix, an option is what an option name is prefixed with for it to be considered an option, this is by default --
    • Reworked the parser system to facilitate option parsers without having duplicate code
      • Changes
        • IArgumentParser (Replaced by IParser)
        • IGenericArgumentParser (Replaced by IGenericParser)
        • IArgumentBeforeParser (Replaced by IBeforeParser)
        • IArgumentAfterParser (Replaced by IAfterParser)
        • ParsedArgument (Replaced by ParsedResult)
      • Added
        • Made all the default parsers in to separate classes, these can be found in com.jockie.bot.core.parser.impl
    • Added IOptionFactory, this is mostly the exactly same as IArgumentFactory only difference being the #createOption instead of #createArgument. OptionFactory#getDefault to get the default factory
    • Added OptionParsingFailurePolicy and ICommand#getOptionParsingFailurePolicy which will be used to determine what to do when an option fails to parse correctly, the possible values are FAIL and IGNORE (default)
    • Added the ability to have multiple sub-commands with the same name (this was only an issue for the automatic generation, you could always add a sub-command with the same name through the addSubCommand method), it would previously just pick one of the available commands without any indication that it did so, making it seem like a bug
  • Changes

    • Removed ArgumentFactoryImpl#setUseShardManager(boolean), this has now been moved to GuildParser and UserParser, registerDiscordParsers now also accepts a boolean useShardManager
    • Renamed AbstractCommand#setInvalidOptionPolicy to #setUnknownOptionPolicy and Argument#invalidOptionPolicy to #unknownOptionPolicy. The class UnknownOptionPolicy was renamed before but for some reason these were not included in the change
    • Removed IArgumentParser#getPriority this has now been moved to the CommandTriggerComparator class (see CommandTriggerComparator#getInstance) and can be set with #setPriority(Class, int). This means that priority is no longer based on the parser and is now based on the type of the argument
  • Bug fixes

    • DuplicateOptionPolicy would not take effect for unknown options

Jockie Utils 1.40 [JDA v4 only]

27 May 12:07
98309d9
Compare
Choose a tag to compare
  • Features

    • Added CommandListener#setCaseSensitivePrefixes and #isCaseSensitivePrefixes, this is used to set whether or not prefixes should be case sensitive or not (by default this is true)
    • StringUtility#asMap now accepts a collection of the quotes to handle, which means ArgumentParsingType#NAMED will now support all CommandParserImpl#getQuoteCharacters quote characters
  • Changes

    • The dummyCommands field for MethodCommandImpl has been changed from private to protected in-case you ever need it for some custom thing. This was the only property which was still private in the whole command implementation chain so I figured I might as well make it protected too
    • The type parameter for IArgumentParser#getParser and #getGenericParser is now @Nullable
    • Removed the default ! prefix, there are now no prefixes for the CommandListener by default
  • Bug fixes

    • Fixed IGenericArgumentParser not handling before and after parsers
    • Fixed null values (for instance, by using nullDefault) for primitive arguments not being converted to their Java default value (for instance, false and 0), causing an exception
    • Fixed CommandListener#getMessageParseFailureFunction returning the help function instead of the message parse function

Jockie Utils 1.39 [JDA v4 only]

15 May 07:55
fe46cc1
Compare
Choose a tag to compare
  • Features

    • Added IErrorManager#unregisterResponse
  • Changes

    • ConfigureBuilderFunction now has a generic type for the argument type, not having the argument type caused issue like not being able to use setDefaultValue without casting the builder
    • Changed all remove methods in IArgumentFactory to use a generic wildcard for both the class and parser to prevent unnecessary complexity for the user
  • Bug fixes

    • Fixed a bug which caused endless arguments to not use the generic builders, this in turn caused enums to not work automatically for endless arguments
    • Fixed a bug which caused endless arguments to not care about the Optional class, if you, for instance, did Optional<String[]> it would not become optional

Jockie Utils 1.38 [JDA v4 only]

11 May 14:02
12fccba
Compare
Choose a tag to compare
  • Features

    • Added more documentation to a lot of methods, documentation includes both @Nonnull and @Nullable
    • Added DuplicateOptionPolicy to ICommand, this option is used to determine what happens when an option is given more than one time, by default, this is set to USE_LAST to be consistent with the previous implementation
      • If you use COMBINE it will return a List of all the provided values, but only if more than one was provided which means this can currently only be used through CommandEvent#getOption
      • If you use FAIL a DuplicateOptionException will be thrown during parsing
    • Added addParserBefore, addParserAfter and addGenericBeforeParser to IArgumentFactory, these are used to modify the content of the argument, the before parser is used to modify the input before it gets to the parser and the after parser is used to modify the output of the parser before it gets to the command
    • Added IArgumentFactory#registerGenericParser, this can be used to, for instance, handle enums without having to make a new parser for every enum (this is a default parser)
    • Added a new interface IPropertyContainer which has the method getProperty, this is extended by IArgument, ICommand and CommandEvent and allows for custom properties (the set methods are exposed through the implementation, IArgument.Builder, AbstractCommand and CommandEvent respectively)
    • You can now get context for the current command class again, for instance, @Context MyCommandClass command
    • You can now use the IContextManager#setEnforcedContext method (it would previously throw an UnsupportedOperationException)
    • Method name to command name conversion will now also handle camel case (helloThere would become hello there) previously it only handled underscores (this only takes effect if the command name is not specified through the @Command annotation)
    • Separated error handling and help handling, error handling is handled through CommandListener#setMessageParseFailureFunction and help is handled through CommandListener#setHelpFunction, previous both were handled through the help function (note that the help function is called through the message parse failure function)
    • Added ICommandEventFactory, which can be set with the CommandListener#setCommandEventFactory method, the factory will be used to create the CommandEvent for a command. Note to use a custom CommandEvent class as a parameter you will have to register it as a context with IContextManager#registerContext as well as IContextManager#setEnforcedContext (the second part is optional but without it, you are going to have to use the @Context annotation)
  • Changes

    • Renamed UnknownOptionException#getOptionString to getOptionKey
    • Renamed ICommand#verify to isAccessible, a slightly more fitting name
    • Renamed CommandListener#parse to handle
    • Changed IOption#getAliases to return List<String> instead String[] to be more consistent with other classes
    • Changed to proper logging instead of using System.out and System.err
    • Better handling of async commands with ordering keys, it will no longer create a new thread for every command that is going to be executed, it will instead queue them and only create a single thread per ordering key

Jockie Utils 1.37

14 Aug 13:13
Compare
Choose a tag to compare
  • Features

    • Added a new property to the @Initialize annotation called recursive which is true by default and only works when subCommands is true as well, this is used to specify whether sub-commands should recursively be initialized or just the top layer
  • Changes

    • Changed the allowedArgumentParsingTypes to only have POSITIONAL by default
    • When subCommand is true in the @Initialize annotation it will now recursively get all commands, to disable this behaviour you can set recursive to false
  • Bug fixes

    • Fixed a bug which caused an exception to be thrown if the command had NAMED as an allowed argument parsing type and you specified an argument without a value like test=
    • Fixed a bug where if you used the @SubCommand annotation to specify nested sub-commands it would not work at all

Jockie Utils 1.36

22 Jul 12:00
Compare
Choose a tag to compare
  • Features

    • Added an @Ignore annotation which can be used to skip commands or modules when loading commands

    • Added Initialize#subCommands, which will determine whether to include sub-commands in the initialization or not, this is false by default

    • Added the ability to add commands and modules by their class to the CommandStore, like commandStore.addCommands(ModuleFun.class)

    • Added IArgument#getErrorConsumer,@Error annotation and IErrorManager which can be used to set a custom error messages for when an argument is parsed incorrectly, for instance @Argument("user") @Error("Invalid user") User user or commandListener.getErrorManager().registerResponse(User.class, "Invalid user")

    • Added CommandListener#addDevelopers(String...) and #removeDevelopers(String...)

    • Added CommandEvent#isFromGuild and #isFromType(ChannelType)

    • Added support for options with values, these can be specified like @Option("option") String option and are used like option=value, only the String type is supported for values (Booleans can also be specified like option=true but that is not required)

    • Added better error handling for CommandStore#loadFrom and #loadModule

    • Added default values for when having nullDefault on a primitive argument, the default values can be found at https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html under Default Values

    • Improved the result returned when the user incorrectly tries to execute a command

    • Improved performance for ReturnManagerImpl and ContextManagerImpl

    • Fixed documentation for JavaDocs

  • Changes

    • Added a getType method to IArgument

    • Added getArgument and getComponentType to IEndlessArgument

    • Added a generic type to IOption as well as a getType method

    • Removed CommandListener#addDeveloper(ISnowflake), #addDeveloper(long), #removeDeveloper(ISnowflake) and #removeSnowflake(long)

    • Removed CommandEvent#getOptionsPresent, added #getOptions, #getOption(String, Class) and getOption(String)

    • Removed the @Arguments annotation, not entirely sure why this was added, it was somewhat useless. I think it was just added to test something new

    • Renamed CommandListener#addCommandStore to #addCommandStores and #removeCommandStore to #removeCommandStores for consistency

    • Reworked the ArgumentFactory to be more consistent with other factories, added IArgumentFactory, ArgumentFactoryImpl and changed ArgumentFactory to return and set the default factory

    • Changed how you get the actual command from a DummyCommand, you now use the getActualCommand method instead of getParent

    • Changed most methods in ArgumentUtiliy to now return a list of results instead of a single entity, the argument parser will however still only accept the argument if there is only a single result

    • Changed IArgument#parse and IArgumentParser#parse to now take ParseContext instead of a Message

    • Changed some default functions in CommandListener

      • Renamed DEFAULT_HELP_FUNCTION to defaultHelpFunction and made it non-static
      • Renamed DEFAULT_MISSING_PERMISSION_FUNCTION to defaultMissingPermissionsFunction and made it non-static
      • Renamed DEFAULT_MISSING_PERMISSION_EXCEPTION_FUNCTION to defaultMissingPermissionExceptionFunction and made it non-static
      • Renamed DEFAULT_MISSING_AUTHOR_PERMISSION_FUNCTION to defaultMissingAuthorPermissionsFunction and made it non-static
      • Renamed DEFAULT_COOLDOWN_FUNCTION to defaultCooldownFunction and made it non-static
      • Renamed DEFAULT_NSFW_FUNCTION to defaultNsfwFunction and made it non-static
    • Changed to use EnumSet in CommandListener for permission related stuff instead of List

    • Changed the order of the parameters in ICommandParser#parse, the trigger parameter is now after prefix instead of after command

    • Moved TriFunction and TriConsumer from com.jockie.bot.core.utility to com.jockie.bot.core.utility.function

  • Bug fixes

    • Fixed ArgumentTrimType and quote characters for endless arguments (closes #14)
    • Fixed a bug which made CommandEvent#removeCooldown and #applyCooldown not function correctly if it was executed as a DummyCommand
    • Fixed a bug with CommandEvent#isPrefixMention which made it not work properly at all, it was checking for a mention without a space but the mention prefix requires a space
    • Fixed a bug with the alternative command implementations which made alternative commands have separate data from their main command, this meant that, for instance, a description could be null instead of the actual description. This also meant that the different implementations would have different cooldown lengths if applied. A side effect of this change is that the command now has to have the exact same data as the main command, meaning that they can't have different permissions and cooldown lengths, which may be desired for some setups

Jockie Utils 1.35

19 Jun 08:24
Compare
Choose a tag to compare
  • Features

    • Added the ability to disable the usage of the ShardManager in arguments such as User and Guild with the ArgumentFactory#setUseShardManager(boolean) method
    • Added the ability to set the command for a command with AbstractCommand#setCommand(String)
    • Added getContext(Class) and getContext(Type) to CommandEvent which are shortcuts for IContextManager#getContext
    • Added replyFormat(String, Object...), replyTyping(), react(Emote) and react(String) to CommandEvent
  • Changes

    • Removed ICommand#getExamples(), I felt like this was just bloat and if the user wants it they can make their own custom command class
    • Moved the Context class from com.jockie.bot.core to com.jockie.bot.core.command
    • Renamed CommandEvent#isDeveloper to isAuthorDeveloper to be more clear
    • Switch places of CommandEvent#getCommand() and getActualCommand() and renamed getActualCommand() to getTriggeredCommand()
  • Bug fixes

    • Fixed inconsistency where some commands would require CommandImpl and some would require AbstractCommand
    • Fixed a cooldown related bug where if you used CommandEvent#applyCooldown(long, TimeUnit) without the command's cooldown duration, ICommand#getCooldownDuration(), being greater than 0 it would not do anything

Jockie Utils 1.34

04 Jun 07:57
Compare
Choose a tag to compare
  • Features

    • Added a JockieUtils class where you can get the github link as well as the current version
    • Properly documented ArgumentFactory and added registerAlias for stuff like primitive data types. Added registerEssentialParsers, registerDiscordParsers and registerJSONParsers as well so you can decide what you want to register, all of these are registered by default
    • Added setAutomaticallyCreateEnums and isAutomaticallyCreateEnums to ArgumentFactory, these are used to set whether or not enum parsers should be created automatically when ArgumentFactory#builder(class) is called if they are not already registered
    • Added CommandExecutionException and changed the way stack traces were printed
    • Added a check for the automatic creation of options to make sure they are booleans
    • Added getPriority to IArgumentParser which will be used to help get the most accurate result when finding commands
    • Added setFilterStackTrace and isFilterStackTrace, this will be used to determine whether or not a stack trace from a command should be filtered to only show the command's stack trace, by default this is true
    • Added removeQuoteCharacter to CommandParserImpl
    • Added getUser, retrieveUser, getUserByIdOrTag and getGuildByIdOrName to ArgumentUtility
    • Added support for ShardManager for some methods in ArgumentUtility
    • Added a default parser for Guild
    • Upgraded the default parser for User to allow for tags and names
    • Upgraded all default Discord entity parsers to use the ShardManager if available
    • The enum parser now allows for enums with an underscore to be defined with spaces if the argument is endless or quoted
  • Changes

    • Renamed registerArgument to registerParser in ArgumentFactory
    • Renamed ArgumentImpl to AbstractArgument
    • Renamed SimpleArgument to ArgumentImpl
    • Renamed of to builder in ArgumentFactory
    • Renamed handleAll to isHandleAll in IArgumentParser
    • Pre-execute checks will no longer ignore errors but instead act as if the command failed to execute and throw a CommandExecutionException
    • Changed quoteCharacters in CommandParserImpl to be a Set instead of List
    • Renamed addAllowedQuoteCharacter to addQuoteCharacter in CommandParserImpl
    • ArgumentTrimType.LINENT will no longer trim arguments with the endless property, for this you would need to use STRICT
  • Bug fixes
    The getPriority property added to IArgumentParsers fixes #13

Jockie Utils 1.33

24 May 08:43
Compare
Choose a tag to compare
  • Features

    • Added a new property ICommand#getArgumentTrimType and Command#argumentTrimType which can be either NONE, LENIENT and STRICT, this will determine how spaces are handled in commands
    • Added setAllowedQuoteCharacters(List<Pair>), addAllowedQuoteCharacter(char, char) and getAllowedQuoteCharacters to CommandParseImpl. This, by default, has quote characters gotten from discord.py
    • AddedIComponentFactory which has the methods createArguments and createOptions which are used in the creation of generated commands
    • Added the ability for command methods to be called on_command instead of just onCommand
    • Added CommandStore#loadFrom(ClassLoader, String, boolean), this can be useful if you are dynamically loading commands
  • Changes

    • Reworked the command structure, IComamnd is now implemented by AbstractCommand which is extended by MethodCommandImpl (implementing IMethodCommand) which is extended by CommandImpl. This rework is to easier allow for custom commands, more information can be seen in the README under Command Extensions