Commit Graph

1330 Commits (master)

Author SHA1 Message Date
blablubbabc 533fbc3aba When replacing arguments in messages, we now abort the matching for an argument after the first match has been found.
This assumes that for every message each argument is used at most once.
Added StringUtils#replaceFirst.
2019-11-11 20:48:28 +01:00
blablubbabc 15967e74ff Preloading another class that might otherwise be missing sometimes during disable. 2019-11-11 20:36:20 +01:00
blablubbabc 3dde001b1a Added various shortcut methods to Text. 2019-11-11 20:08:23 +01:00
blablubbabc b4dfef0289 Added support for translation arguments for the Spigot-specific text features. 2019-11-11 19:42:03 +01:00
blablubbabc fa8a510e38 Removed more redundant shopkeeper name null checks. 2019-11-11 18:29:36 +01:00
blablubbabc d1a10563e6 Added support for Spigot specific text features (not used yet).
Those will only be available when run on a Spigot-based server.

Other changes:
* Added a few new utility methods to TextUtils.
* Slightly changed how TextUtils#getPlayerString deals with a missing player name.
* Made CollectionUtils#getIdealHashMapCapacity public.
2019-11-11 18:26:21 +01:00
blablubbabc 02f2a65f41 Added validation that the unique id of loaded or freshly created shopkeepers is not yet used. 2019-11-10 19:38:42 +01:00
blablubbabc 25a1320b69 Removed various redundant null checks (shop names, shop owner uuids). 2019-11-10 15:04:36 +01:00
blablubbabc 85cbe64303 The regex pattern used to validate shopkeeper names gets precompiled now. 2019-11-09 15:42:55 +01:00
blablubbabc 3a100eb981 More preparations for virtual shopkeepers.
Added ShopkeeperRegistry#getVirtualShopkeepers()
2019-11-09 13:47:57 +01:00
blablubbabc b782fb5a43 Exclude virtual shops from worlds_with_shops metric. 2019-11-09 12:52:49 +01:00
blablubbabc e5185f7644 Player shops are required to always provide a valid owner name now.
Previously it would use 'unknown' as fallback name.

API: Renamed PlayerShopkeeper#getOwnerAsString to #getOwnerString.
API: Added Shopkeeper#getIdString.
2019-11-09 00:25:29 +01:00
blablubbabc c1291a5cdd Made some preparations to support virtual shopkeepers in the future (which are not located in any world). Various location related API methods may now return null.
Also: We explicitly check for missing world names when loading shopkeepers now.
2019-11-08 22:57:33 +01:00
blablubbabc 8f27ff1763 Removed various API methods from Shopkeeper which simply delegated to the corresponding shop object.
Also moved ShopObjectType#needsSpawning into ShopObject.
2019-11-08 22:43:59 +01:00
blablubbabc 9e9c4efd68 Added more information to the message that gets logged when a shopkeeper gets removed for owner inactivity.
Also slightly changed the text format that gets used at a few places to represent a player's name and uuid.
2019-11-08 22:14:00 +01:00
blablubbabc cfbf673cdd Fixed: We would previously drop the shop-creation item returned on shop deletion at the shop's location, even if the shop got deleted via remote editing from far away (and is potentially not even loaded).
If the player is further than 10 blocks away (or if the shop object is not loaded), it will drop the item at the player's location now.
2019-11-08 19:47:26 +01:00
blablubbabc aad85f15a3 The next version will be 2.9.0. 2019-11-08 15:10:57 +01:00
blablubbabc 38a8c0f39f Normalized the representation of various multi-line messages inside the default config.
Affected:
* msg-creation-item-selected
* msg-shop-setup-desc-selling
* msg-shop-setup-desc-buying
* msg-shop-setup-desc-trading
* msg-shop-setup-desc-book
* msg-shop-setup-desc-admin-regular
2019-11-08 15:09:13 +01:00
blablubbabc 2b4d8bbe71 Using a shared yaml config instance for utility functions. 2019-11-08 13:49:17 +01:00
blablubbabc 9bc08560f5 Moved config section clearing into ConfigUtils class. 2019-11-08 13:47:59 +01:00
blablubbabc e7a258dd0a Fixed: The book shopkeeper would not correctly store offers for books that have dots in their name.
Removed the importing of old book offers (from late MC 1.12.2, see v1.83). When updating from an older version of Shopkeepers, you will have to first update to a version in-between.
2019-11-08 12:54:41 +01:00
blablubbabc 022c1d527b The ids used for storing shopkeeper offers start at 1 now (instead of 0).
This has no impact on the loading of save data, but makes it nicer to read.
2019-11-08 12:46:27 +01:00
blablubbabc 72cdeb79f0 Fixed: Some settings would not loaded correctly depending on the used locale.
Also made all other text comparisons locale independent.
2019-11-08 12:08:36 +01:00
blablubbabc 434b08045c Merge remote-tracking branch 'origin/master' 2019-11-05 17:49:40 +01:00
blablubbabc 3d5545c1bd Missing changes from previous commit(s). 2019-11-05 17:33:18 +01:00
blablubbabc a7ab69e81e Omitting color conversion for setting 'debug-options'. 2019-11-05 17:31:06 +01:00
blablubbabc 4283b1ea4a ShopkeeperStorage is supposed to be using the async fileEncoding setting. 2019-11-05 17:28:30 +01:00
blablubbabc 790d8da3a3 Various fallback related fixes and other command related changes and additions.
* Fixed: Command#handleFallbacks was missing a return when the fallback did not consume any of the remaining input arguments.
* Fixed fallback handling for optional and FirstOf arguments.
* Added display name property to all command arguments. This can be used to change the name that is used to represent the argument in the command format. This replaces the previous AliasArgument. This is especially useful for conflicting literal arguments. Literal arguments will omit their actual name from the argument completions if a different display name has been set.
* Added TypedFirstOfArgument, a variant of FirstOfArgument that preserves the result type of its child arguments.
* Made FallbackArgument abstract and added specializations AnyFallbackArgument and TypedFallbackArgument.
* Added NameArgument, which can be useful if there would otherwise be conflicts / ambiguities between arguments.
* Added debug option 'commands' and added various debug output when parsing and executing a command.
* ArgumentParseException provides the command argument that created it now. This is especially useful for debugging purposes.
* Minor changes to ArgumentsReader in order to make debugging easier.
* Minor formatting at a few places.
2019-11-05 17:25:10 +01:00
blablubbabc e723475afb Fixed previous commit: Warning message being printed for default language file missing. 2019-11-02 14:56:48 +01:00
blablubbabc ef96d322ec Changed the new argument fallback mechanic slightly:
Previously it would abort the parsing beyond the fallback after the
first command argument was able to successfully parse an argument from
the input. In some cases this is however not sufficient to determine
whether parsing past the fallback succeeds or not.
Example: Command "/list [player] [page]" with input "/list 123 2": '123'
is a rare but valid player name. We want to use the fallback mechanic as
heuristic, but still be able to correctly parse the input if both
arguments are specified explicitly.
Previously '123' would get interpreted as page number, causing the
overall parsing to fail to due an unparsed argument at the end.
The fallback mechanic was changed to now try to fully parse the input
beyond the fallback. If there are remaining unparsed arguments, the
parsing past the fallback is considered to have failed and will then
lead to the fallback to be used (accepting any input for the player
name), resulting in the above example to get parsed correctly again.

Other command related changes:
* Split up the Command#parseArguments function into separate parts.
* Replaced CommandArgs with ArgumentsReader: The arguments are now
stored inside the CommandInput and the ArgumentsReader only references
them from there.
* CommandContext is now an interface (with SimpleCommandContext as
implementation). A new class CommandContextView was added that gets used
anywhere where accessing the context is allowed, while modifying is not.
* BufferedCommandContext#getMapView() was fixed. This now creates a new
SimpleCommandContext with the combined values.
* Command and tab completion handling was moved from BaseCommand into
Command.
* Resetting of the arguments reader if parsing of an command argument
failed was moved from CommandArgument#parse into Command.
* Removed the lazy initialization of Command's argument list and
CommandContext's values map. ArrayList and LinkedHashMap are smart
enough to not actually allocate the internal array until it is required
for the first element.
* Removed Guava dependency for reverse iterating arguments in Command
class.
* Command#parseArguments will now check for unexpected input arguments
even if the command doesn't use any arguments.
2019-10-31 12:53:14 +01:00
blablubbabc fc499c494a Added marker interface for the CommandArgs state.
Also:
* Added CommandArgs#copy. Since the underlying arguments are expected to never change, they are not actually copied (only the parsing state is copied). Any captured CommandArgs states are applicable to the copy as well.
* Added CommandContext#copy() and made constructor CommandContext(otherContext) protected.
* Added TODO note on implementing OptionalArgument always via fallbacks.
2019-10-22 04:25:44 +02:00
blablubbabc 72af1e52b6 More brainstorming regarding argument ambiguities. 2019-10-22 03:00:41 +02:00
blablubbabc f2c0ca4245 Reverted: Removed PostponedArgumentException again.
This isn't currently used anywhere and most usecases for this are probably covered by the new fallback mechanic anyways now. Removing it simplifies the parsing procedure.
2019-10-21 21:33:59 +02:00
blablubbabc 0c05ba9369 Moved default shopkeeper argument filters into ShopkeeperFilter class/namespace. 2019-10-21 21:07:48 +02:00
blablubbabc 0b2bb46b5f Minor changes. 2019-10-21 21:02:07 +02:00
blablubbabc 51944d4648 Made CommandArgument#getDefaultErrorMsgArgs public in order to also use it for messages created by ArgumentFilters.
Avoiding using Utils#concat in favor of new utility methods inside TextUtils.
Minor parameter renaming for ArgumentFilter.
2019-10-21 02:39:20 +02:00
blablubbabc 949de1927d Fix previous change: CommandArgument#getDefaultErrorMsgArgs was missing
the actual message arguments.
2019-10-21 01:58:57 +02:00
blablubbabc 78065d5281 The plugin will now shutdown in case a severe issue prevents loading the config.
This includes the case that the config version is invalid. Previously it would treat invalid and missing config versions the same and apply config migrations nevertheless.

Also separated config and language file loading, and changed/added a few information/warning messages related to config and language file loading.
2019-10-20 02:52:59 +02:00
blablubbabc 5354367bce ConversionUtils: Removed unnecessary null checks. 2019-10-20 01:30:28 +02:00
blablubbabc 998e62e105 Missing changes related to the changes made to message msg-list-shops-entry. 2019-10-19 00:21:49 +02:00
blablubbabc fdf148eff8 The german translation for message 'msg-villager-for-hire' was slightly changed. 2019-10-18 01:50:24 +02:00
blablubbabc 3ef1adf2f5 The default german translation contained a few no longer used messages.
msg-button-type and msg-button-type-lore were removed.

Also added a header to the german translation.
2019-10-18 01:38:23 +02:00
blablubbabc 61261343a3 Changed message msg-list-shops-entry.
'object type' changed to 'object', and the arguments '{shopSessionId}' and '{shopId}' changed to '{shopId}' and '{shopUUID}' respectively. Argument '{shopSessionId}' still works but will likely get removed in the future.

Also fixed: The internal default for message 'msg-list-shops-entry' (that gets used if the message is missing in the config) was not matching the message in the default config.
2019-10-18 01:23:28 +02:00
blablubbabc 19cd2aa831 Misc. 2019-10-17 21:07:50 +02:00
blablubbabc c97bb0952c Added ShopkeepersStartupEvent.
This can be used by plugins to make registrations during Shopkeepers' startup process (eg. to register custom shop types, object types, etc.). This event is marked as deprecated because custom shop types, object types, etc. are not yet officially supported as part of the API. Also, the event is called so early that the plugin (and thereby the API) are not yet fully setup and ready to be used, so this event is only of use for plugins which know what they are doing.

Default shop, object and ui types are getting registered early during onLoad now (similar to config loading).
2019-10-17 19:45:46 +02:00
blablubbabc 13006722f3 Fixed/API: NPE when accessing a non-existing second offered item from the ShopkeeperTradeEvent.
Fixed/API: The offered items inside the ShopkeeperTradeEvent are copies now and their stack sizes match those of the trading recipe.
2019-10-17 18:08:51 +02:00
blablubbabc 34d4a5b311 Only printing the 'Config already loaded' message during startup if the debug mode is enabled. 2019-10-17 18:06:06 +02:00
blablubbabc a66e8bb229 Fixed: Improved thread-safety for asynchronous logging operations and settings access.
Internal: Added Settings#isDebugging and Settings#isDebugging(option) to conveniently (and thread-safe) check for debugging options.
2019-10-17 18:03:55 +02:00
blablubbabc b2a0fff74d Fixed: Derived settings were not updated when loading messages from a separate language file. 2019-10-17 16:20:38 +02:00
blablubbabc 58f3f7af31 bstats gets shaded into the package '[..].libs.bstats' now. 2019-10-17 16:04:48 +02:00