Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands and translations overhaul #105

Merged
merged 100 commits into from
May 23, 2024

Conversation

Grabsky
Copy link
Contributor

@Grabsky Grabsky commented Apr 18, 2024

DESCRIPTION

Goals of this PR:

  1. Improve usability of commands, by using more advanced features like parameter arguments or context-aware suggestions.
  2. Improve UX when interacting with certain commands or plugin components, by re-working the default translations.
  3. Bring multi-language support for translations.

Migrating commands to a framework is necessary to implement some planned features much easier. Cloud v2 has been chosen because of (1) extensible API, (2) annotations module, (3) brigadier support, (3) maturity and recognition.

Translations system provided by FancyLib should make interacting with translations cleaner.

FIXES

Fixes #81

Common states (collidable, glowing, show_in_tab, turn_to_player) can now be toggled. Attribute values cannot be toggled with the current attribute system, at least not without unnecessary parsing and guessing the value type.

Fixes #86

Unable to reproduce the issue with this build.

Fixes #87

Equipment is no longer reset after changing NPC type to other living-entity. No modification GUI but improvements to equipment sub-command family.


TO-DO

  • Fix all blocking issues:
    • @Default annotation not working on flags.
    • Location argument suggestions not working properly.
    • Translator utility not updating the file with new contents.
    • Translator utility throwing NPE non-existent messags, translation key should be printed instead.
  • Port all commands the new framework.
  • Map Cloud captions to plugin translations, preferably using exception handlers.
  • Final tweaks and improvements to commands.
  • Final tweaks and improvements to default translations.
  • Write detailed changelog with all changes introduced by this PR.
  • Test on versions other than 1.20.6.

TO-DO (OPTIONAL, NON-BLOCKING)

  • Replace temporary ExceptionHandlerRegistration for LocationParser.LocationParseException with a regular ExceptionHandler. Depends on Incendo/cloud-minecraft (#70).

CHANGLOG / REFERENCE

Important / Breaking Changes

  1. Command permissions have been renamed and now follow a fancynpcs.command.(command).(sub) format. New permissions are listed below.
  2. Some commands have had their syntax modified to support new features. Changes are listed below.
  3. Some sub-commands have been renamed to use snake_case instead of lowerCamelCase. These sub-commands are:
    • interactionCooldowninteraction_cooldown
    • turnToPlayerturn_to_player
    • showInTabshow_in_tab
    • serverCommandserver_command
    • playerCommandplayer_command
  4. Localization has been reworked.
    • New system supports multiple languages and these can be defined inside FancyNpcs/language/ directory.
    • Language can be changed globally (for all players) inside the plugin configuration (config.yml).
    • Currently, only english (en.yml) locale is bundled with the plugin.
    • Old localization file (lang.yml) is no longer used by the plugin.

Command Reference

/fancynpcs feature_flags

  • Syntax: /fancynpcs feature_flags
  • Permissions: fancynpcs.command.fancynpcs.feature_flags
  • Formerly known as /fancynpcs featureFlags.

/fancynpcs reload

  • Syntax: /fancynpcs reload
  • Permissions: fancynpcs.command.fancynpcs.reload

/fancynpcs save

  • Syntax: /fancynpcs save
  • Permissions: fancynpcs.command.fancynpcs.save

/fancynpcs version

  • Syntax: /fancynpcs version
  • Permissions: fancynpcs.command.fancynpcs.version

/npc attribute

  • Syntax: /npc attribute (npc) (set | list)
  • Permissions: fancynpcs.command.npc.attribute.(sub)
  • Listing attributes is now possible with list sub-command.

/npc collidable

  • Syntax: /npc collidable (npc) [state]
  • Permissions: fancynpcs.command.npc.collidable
  • Can now be "toggled" when [state] argument is not specified.

/npc copy

  • Syntax: /npc copy (npc) (new_name)
  • Permissions: fancynpcs.command.npc.copy
  • Name check is now more strict and only allows A-Z a-z 0-9 _ - / characters.

/npc create

  • Syntax: /npc create (name) [--position (x y z)] [--world (world)] [--type (type)]
  • Permissions: fancynpcs.command.npc.create
  • Basic customization has been added via parameter flags.
  • Name check is now more strict and only allows A-Z a-z 0-9 _ - / characters.

/npc displayname

  • Syntax: /npc displayname (npc) (@none | name)
  • Permissions: fancynpcs.command.npc.displayname
  • Empty message placeholder is now @none instead of <empty>.

/npc equipment

  • Syntax: /npc equipment (npc) (set | clear | list)
  • Permissions: fancynpcs.command.npc.equipment.(sub)
  • Clearing entries is now possible with clear sub-command`.
  • Listing entries is now possible with list sub-command.
  • Now accepts either @none, @hand or valid item type as an argument.

/npc fix

  • Syntax: /npc fix (npc)
  • Permissions: fancynpcs.command.npc.fix

/npc glowingColor

  • Command has been removed and additional functionality has been added to /npc glowing command.

/npc glowing

  • Syntax: /npc glowing (npc) [disabled | color]
  • Permissions: fancynpcs.command.npc.glowing
  • Now, instead of true or false, accepts disabled or color as an argument.
  • Can now be "toggled" when [disabled | color] argument is not specified.

/npc help

  • Syntax: /npc help [page]
  • Permissions: fancynpcs.command.npc.help
  • Is now cleaner and richer in information, command description is now available upon hover.
  • Contents is nwo split across multiple pages.

/npc info

  • Syntax: /npc info (npc)
  • Permissions: fancynpcs.command.npc.info
  • Is now cleaner and richer in information. Some values can be copied and a few others redirect to a different command.

/npc interaction_cooldown

  • Syntax: /npc interaction_cooldown (npc) (disabled | cooldown)
  • Permissions: fancynpcs.command.npc.interaction_cooldown
  • Formerly known as /npc interactionCooldown.
  • Now uses time duration instead of a number of seconds eg. 2min. Supported units:
    • milliseconds: ms
    • seconds: s
    • minutes: min
    • hours: h
    • days: d
    • months: mo
    • years: y

/npc list

  • Syntax: /npc list [--type (type)] [--sort (sort)]
  • Permissions: fancynpcs.command.npc.list
  • Now supports basic filtering and sorting via parameter flags.

/npc message

  • Syntax: /npc message (npc) (add | set | remove | clear | list | send_randmly)
  • Permissions: fancynpcs.command.npc.message.(sub)
  • Empty message placeholder is now @none instead of <none>.
  • Improved blocked command check and now only the base command is compared.

/npc move_here

  • Syntax: /npc move_here (npc)
  • Permissions: fancynpcs.command.npc.move_here
  • Formerly known as /npc moveHere.

/npc move_to

  • Syntax: /npc move_to (npc) (x) (y) (z) [world] [--look-in-my-direction]
  • Permissions: fancynpcs.command.npc.move_to
  • Formerly known as /npc teleport.
  • Can now be executed from the console.
  • Now supports --look-in-my-direction presence flag that makes NPC turn in direction player is currently standing at.

/npc nearby

  • Syntax: /npc nearby [--radius (radius)] [--type (type)] [--sort (sort)]
  • Permissions: fancynpcs.command.npc.nearby
  • This is a new command. Similar to list sub-command but only lists NPCs in player's world.

/npc player_command

  • Syntax: /npc player_command (npc) (add | set | remove | clear | list)
  • Permissions: fancynpcs.command.npc.player_command.(sub)
  • Formerly known as /npc playerCommand.
  • Improved blocked command check and now only the base command is compared.

/npc remove

  • Syntax: /npc remove (npc)
  • Permissions: fancynpcs.command.npc.remove

/npc server_command

  • Syntax: /npc server_command (npc) (add | set | remove | clear | list)
  • Permissions: fancynpcs.command.npc.server_command.(sub)
  • Formerly known as /npc serverCommand.
  • Improved blocked command check and now only the base command is compared.
  • Now supports multiple entries.

/npc show_in_tab

  • Syntax: /npc show_in_tab (npc) [state]
  • Permissions: fancynpcs.command.npc.show_in_tab
  • Formerly known as /npc showInTab.
  • Can now be "toggled" when [state] argument is not specified.

/npc mirrorSkin

  • Command has been removed and additional functionality has been added to /npc skin command.

/npc skin

  • Syntax: /npc skin (npc) (@none | @mirror | name | url)
  • Permissions: fancynpcs.command.npc.skin
  • Now supports removing skin using @none flag.
  • Now supports skin mirroring using @mirror flag.

/npc teleport

  • Syntax: /npc teleport (npc)
  • Permissions: fancynpcs.command.npc.teleport
  • Now teleports sender to the NPC. Teleportng the NPC to specified location is now handled by /npc move_to command.

/npc turn_to_player

  • Syntax: /npc turn_to_player (npc) [state]
  • Permissions: fancynpcs.command.npc.turn_to_player
  • Formerly known as /npc turnToPlayer.
  • Can now be "toggled" when [state] argument is not specified.

/npc type

  • Syntax: /npc type (npc) (type)
  • Permissions: fancynpcs.command.npc.type

@Grabsky Grabsky marked this pull request as ready for review May 20, 2024 17:15
Copy link
Member

@OliverSchlueter OliverSchlueter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OliverSchlueter
Copy link
Member

I'm going to go through all commands in-game and if it looks good to me, it will be merged, so the community can test these very fancy new command system.

@OliverSchlueter OliverSchlueter merged commit 40cff59 into FancyMcPlugins:main May 23, 2024
@Grabsky Grabsky deleted the feature/commands-v2 branch May 24, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants