Commit Graph

8 Commits (master)

Author SHA1 Message Date
blablubbabc 55ed27979e Refactor: Improved handling of unknown materials and issues during ItemData deserialization. 2020-11-28 17:45:33 +01:00
blablubbabc de274ae203 Added test cases to validate the default config and language files. 2020-11-23 15:01:13 +01:00
blablubbabc 4080de2387 Separated messages from the config.
* We always generate an 'en-default' language file. This file acts as a
template for custom language files. It is not meant to be modified and
is replaced with an up-to-date version on every plugin startup.
* Config: Changed the default language from 'en' to 'en-default'.
Existing configs get automatically migrated.
* Fixed: Text#parse can now also parse alternative color codes starting
with '&'. This has an effect when some messages of the specified
language file cannot be loaded and the plugin then uses the default
messages instead. This is part of Text#parse now (instead of requiring a
separate color conversion) for convenience reasons.
* Added warning output when the language file misses messages, or
contains unexpected messages.
* All message keys were changed to no longer start with the 'msg'
prefix.
2020-11-21 18:51:18 +01:00
blablubbabc 84176f1f49 Various command and text changes.
Command changes:
* Changed: The list and remove commands accept player uuids now and ignore the case when comparing player names.
* Changed: The list and remove commands handle ambiguous player names now: If there are shops of different players matching the given player name, an error message is shown and the player needs to be specified by uuid instead. If a player with matching name is online, that player is used for the command (regardless of if the given player name is ambiguous).
* Changed: The shops affected by the remove command are now determined before asking for the users confirmation. This allows detecting ambiguous player names and missing player information before prompting the command executor for confirmation. A minor side effect of this is that any shops created after the command invocation are no longer affected by the remove command once it gets confirmed.
* Internal: Refactored ObjectIdArgument and all player/shopkeeper name/uuid/id arguments.
  * Added ObjectByIdArgument which contains most of the shared logic now.
  * Added ShopkeeperIdArgument.
  * Added TransformedArgument which allows transforming of parsed arguments.
  * Various refactoring to name/id matching.

Text changes:
* Added: The list and remove commands now show the player's uuid as hover text and allow it to be copied into the chat input via shift clicking.
* Internal: Made various changes in order to support Minecraft's text features such as hover events, click events, insertions, etc.:
  * Text was changed to more closely match the behavior of text with legacy color codes.
  * Most texts are now parsed and stored in a new format internally.
  * Text and TextBuilder allow for fluent Text construction.
  * Moved everything Text related into separate package.
  * SpigotText isn't used directly anymore, but via TextUtils.
  * The commands library was updated to use the new text representation everywhere now.
* Internal: Various changes to TextUtils and argument replacement:
  * Arguments can be arbitrary objects now and Suppliers can be used to dynamically lookup argument values.
  * By iterating over the input String only once and using a map for argument lookup, the replacement of arguments in plain text should be faster now.
  * Placeholders in the new Text-based text get parsed only once at plugin startup and use a Map based argument lookup as well, so replacement should be faster there as well.
  * Placeholder keys are now specified without the surrounding braces.
  * Moved newline pattern and splitting into StringUtils.
  * Started moving common shopkeeper message arguments into AbstractShopkeeper. But this is not used yet.
* Added a few StringUtils and Text tests.

Changed messages:
* Added {shopsCount} argument to shop removal confirmation messages:
  * msg-confirm-remove-admin-shops
  * msg-confirm-remove-own-shops
  * msg-confirm-remove-player-shops
  * msg-confirm-remove-all-player-shops

New messages:
* msg-ambiguous-player-name
* msg-ambiguous-player-name-entry
* msg-ambiguous-player-name-more
2019-12-27 03:45:36 +01:00
blablubbabc df91a77ed0 Renamed AbstractTestBase to AbstractBukkitTest. 2019-12-26 01:10:35 +01:00
blablubbabc 1b6c4146de Added new debug command "/shopkeepers yaml".
This prints Bukkit's yaml serialization and the item data representation
used in the config for the currently held item.
2019-08-19 06:39:55 +02:00
blablubbabc 93a59f712c Fixed: ItemData deserialization modifying the original data map. 2019-08-18 08:10:22 +02:00
blablubbabc 37b68085f8 Changed how items are getting defined in the config.
Internally this new format uses Bukkit's item serialization for parsing
the item data, which allows it to support the specification of arbitrary
item data and hopefully not require any major updating/maintenance for
future minecraft versions. At the same time it tries to stay (slightly)
more user-friendly than Bukkit's item serialization by omitting any data
that can be restored by the plugin, by avoiding one level of nesting
between the item type and item data, by translating ampersand ('&')
color codes in display name and lore, and by offering a compact
representation for specifying an item only by its type.

This change also allows a more detailed specification of some of the
editor button items. However, many editor buttons still miss
corresponding config settings. Also keep in mind that the display name
and lore for these button items get specified via corresponding message
settings, so any specified item display name and lore will get replaced
by that.

When checking if an in-game item matches the item data specified in the
config, only the specified data gets compared. So this does not check
for item data equality, but instead the checked item is able to contain
additional data but still get matched (like before, but previously this
was limited to checking display name and lore).

The previous item data gets automatically migrated to the new format
(config version 2).

Other changes:
* Internal: Moved config migrations into a separate package.
* Internal: Moved some function(s) into ConfigUtils.
* Internal: Slightly changed how the plugin checks whether the high
currency is enabled.
* Internal: Avoiding ItemStack#hasItemMeta calls before getting an
item's ItemMeta, since this might be heavier than simply getting the
ItemMeta directly and performing only the relevant checks on that.
Internally ItemStack#hasItemMeta checks emptiness for all item
attributes and might (for CraftItemStacks) even first copy all the
item's data into a new ItemMeta object. And even if the item actually
has no data (Bukkit ItemStack with null ItemMeta), ItemStack#getItemMeta
will simply create a new empty ItemMeta object without having to copy
any data, so this is still a similarly lightweight operation anyways.
* Internal: Added ItemData tests. Unfortunately this requires
CraftBukkit as test dependency.
2019-08-18 04:51:49 +02:00