Commit Graph

1330 Commits (master)

Author SHA1 Message Date
blablubbabc 6809a8d7ac FallbackArgument delegates to another argument for its fallback implementation now.
Moved some of the logic for determining which exception to use when handling fallbacks into Command and FallbackArgument itself. For the most part the behavior there is as before, but if a fallback failes due to missing an argument or requiring a player, the parsing exception of the original (root) argument is preferred. If the parsing context has changed (ag. if some of the following command arguments were able to parse something), the original argument may get reevaluated to determine the new error.

Other command related changes:
* Clarified CommandArgument#isOptional javadoc.
* Added some notes and TODO entries on remaining issues with ambiguities.
* Renamed FallbackArgumentException#getArgument to #getFallbackArgument.
* Added FallbackArgument#getOriginalArgument.
* Added MissingArgumentException and InvalidArgumentException (which ArgumentRejectedException extends) which allows specifically handling those types of exceptions.
* Renamed CommandArgument#missingArgument and #invalidArgument to #missingArgumentError and #invalidArgumentError.
* Added CommandArgument#requiresPlayerError, RequiresPlayerArgumentException and a corresponding default message (msg-command-argument-requires-player) for arguments that require a player as executor.
* PostponedArgumentParseException wraps another exception now which gets thrown by the command in place of the postponed exception itself. This allows providing context about the type of the postponed exception.
* Added PostponedArgumentParseException#getRootException.
* Using an Optional to indicate whether an argument's parent has already been set vs whether it has no parent.
* Making sure that the command argument parent isn't set to the argument itself.
* Fixed parent validation in Command#addArgument.
* Added: Validating that no arguments with the same name are added to the same command.

Other changes:
* Added Utils#concat() for arrays.
2019-10-17 15:28:53 +02:00
blablubbabc d7d882c3f1 Minor changelog fixes. 2019-10-16 04:30:14 +02:00
blablubbabc 53659dedd8 CommandArgument#parse now also returns the parsed value.
This is useful when there is a chain of wrapped arguments and the parent
needs to handle the value parsed by the child argument in some way.

Fixed: Chains of FirstOfArguments should now be able to properly store all the values parsed by child arguments along the chain. Previously this only worked for a chain depth of 1.
2019-10-10 19:26:55 +02:00
blablubbabc d88300d590 Minor changes to handling errors during command handling.
Besides the stack trace, the plugin also logs the command context
(parsed arguments) now.

Added map view and toString to CommandContext.
2019-10-10 19:15:33 +02:00
blablubbabc f743bcaa0b Added AliasArgument.
This can be used to change the display name of an command argument (used
in the command format). This may for example be useful in the presence
of multiple, otherwise conflicting literal arguments.
2019-10-05 01:25:13 +02:00
blablubbabc 6a6e55a706
Update README.md 2019-09-23 01:19:04 +02:00
blablubbabc 83b5bf880f CommandArguments keep track of their parent argument now (if used
internally by another argument) and use that for their error messages.
2019-09-09 15:02:27 +02:00
blablubbabc f07ef4a334 Fixed: The shop creation item can no longer be used from dispensers if
regular use is disabled.

TODO: Only do this for items with special dispensing behavior.
TODO: Drop the item instead.
2019-09-09 13:08:43 +02:00
blablubbabc c6454d26ae Method missing in previous commit. 2019-09-07 18:26:40 +02:00
blablubbabc 88a48a216d Various (mostly internal) changes to commands and argument parsing.
Added new fallback mechanism for arguments.
2019-09-07 18:16:30 +02:00
blablubbabc 607cf3866b Updated TODO 2019-08-31 16:20:33 +02:00
blablubbabc cdb843e665 Fixed: Commands would sometimes not correctly recognize the targeted
shopkeeper entity.

This is caused by SPIGOT-5228 keeping dead invisible entities around,
which get ignored now by the commands.
2019-08-29 16:18:19 +02:00
blablubbabc b028dac087 Prepared working on the next version. 2019-08-23 17:01:11 +02:00
blablubbabc 5b50dfc18c Version 2.8.1 2019-08-23 16:54:47 +02:00
blablubbabc 72c6902917 * Fixed: An issue introduced in the previous update prevented players
from using the shop creation item if the item's regular usage got
disabled in the config.
2019-08-23 16:53:34 +02:00
blablubbabc 922362dbb9 Refactoring: Using our own Validation class, since the one bundled in
Bukkit is outdated and missing some features.

The API package still uses the bundled one (for now) to avoid moving
implementation utils into the API.

Also added a few more functions to StringUtils.
2019-08-23 08:39:56 +02:00
blablubbabc fb68c0c50b Cancelling all EntityTransformEvents involving shopkeeper entities.
This replaces the previously used workaround for preventing villagers
struck by lightning turning into witches.
2019-08-22 14:34:01 +02:00
blablubbabc d9f06f0996 Refactoring: Moved lots of utilities from Utils class into more specific
utility classes.
2019-08-22 14:27:40 +02:00
blablubbabc 9cf987a6bf Updated changelog. 2019-08-22 01:14:52 +02:00
blablubbabc c33d9ebe04 Added a comment about the available debug options to the config.
Also moved the declaration of the available debug options into a
sub-class inside Settings.
2019-08-22 01:05:13 +02:00
blablubbabc e69f57c3d1 Prepared working on the next version. 2019-08-22 00:23:14 +02:00
blablubbabc d38c02a0f2 Version 2.8.0 2019-08-22 00:10:04 +02:00
blablubbabc 5018007671 Slightly improved performance for handling block physics events. 2019-08-21 10:37:36 +02:00
blablubbabc cab360d3fc Major performance improvement for handling items moving between
inventories (for hoppers, droppers, etc.)

This is mainly achieved by avoiding creating the inventory holder (block
snapshot) of the involved inventories, and also by avoiding duplicate
protection checks for double chests.
2019-08-21 10:34:05 +02:00
blablubbabc b5bd66902d Added an additional comment inside the default config that refers to the
wiki for an explanation on how item data gets specified inside the
config.
2019-08-21 05:12:49 +02:00
blablubbabc 8b90b348d9 Minor changes to the "checkitem" command.
It nows compares the items in main and off hand and also checks if the
item in the main hand matches the item in the off-hand.
2019-08-20 04:32:30 +02:00
blablubbabc 5437c5d457 Further attempt to resolve some Eclipse issue. 2019-08-20 04:26:04 +02:00
blablubbabc 066828e4be Added the config setting 'register-world-guard-allow-shop-flag'
(default: true).

This can be used to disable the registration of the 'allow-shop'
WorldGuard flag. Usually this should not be required though. Note that
changing this setting has no effect until the next server restart or
full server reload.

This replaces the just previously added system property
'shopkeepers.skip-wg-allow-shop-flag' again.
2019-08-20 00:41:33 +02:00
blablubbabc 1939c02877 Added a system property 'shopkeepers.skip-wg-allow-shop-flag' which can
be used to disable the registration of the 'allow-shop' WorldGuard flag.

This should usually not be required though.

Also moved some initialization and config loading into the onLoad phase,
so that it is available for any code running there.
2019-08-19 23:46:24 +02:00
blablubbabc 2a197e439e Trying to solve some issue Eclipse is having with our 'unconventional'
maven project structure by also compiling the source code at the root
project.
2019-08-19 23:14:34 +02: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 48f0a06dd4 Also reporting dead and invalid entities retrieved from chunks in
shopkeepers' "check" command output.

Those seem to sometimes differ from the entities retrieved from the
world.
2019-08-19 04:32:09 +02:00
blablubbabc c55162252e Added entity, invalid entity and dead entity count to shopkeeper's
"check" command.

Also restructured the output slightly to make it more compact and
clearer.
2019-08-19 00:54:31 +02:00
blablubbabc d9b4e054ab Changelog categories. Should also make the formatting more compact on
github.
2019-08-18 09:40:13 +02:00
blablubbabc 4dccd1660d Added: The previous, current and next page items inside the editor view
will now use their stack size to visualize the previous, current and
next page number.

This even works for items which are usually not stackable.
2019-08-18 09:11:15 +02:00
blablubbabc cf1635eaa6 Fixed: Also updating default config version to 2. 2019-08-18 08:21:17 +02:00
blablubbabc 93a59f712c Fixed: ItemData deserialization modifying the original data map. 2019-08-18 08:10:22 +02:00
blablubbabc 99ed5dc976 Try to persist original item data position in config during migration. 2019-08-18 08:09:28 +02:00
blablubbabc 43fae6161b Renamed the setting 'high-zero-currency-item' to
'zero-high-currency-item'. This gets automatically updated during the
migration.

Also fixes an issue with the previous migration of this item.
2019-08-18 06:02:54 +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
blablubbabc 490ceb42fb Bumped Bukkit dependency from 1.14.3 to 1.14.4. 2019-08-17 09:03:16 +02:00
blablubbabc be5a8597cb Added interfaces for the different shopkeeper types and their offers to
the API. They allow modifying the shopkeepers' trades. Factory methods
for the different types of offers are provided via ShopkeepersPlugin and
ShopkeepersAPI.

* The internal shopkeeper classes got renamed.
* API: Added a few utility methods to TradingRecipe for comparing the
recipes with given items or other recipes.
* API: Added toString, hashCode and equals to TradingRecipe and the new
offer types.
* Minor javadoc changes.
* Fixed: ShopkeepersAPI was missing getDefaultUITypes.
2019-08-12 21:00:22 +02:00
blablubbabc 3e888f4d56 Added a test to ensure consistency between ShopkeepersPlugin and
ShopkeepersAPI.

Adjusted Eclipse classpath to make tests work. There seems to be
something off with the maven setup for the individual child modules
though.
2019-08-12 20:55:32 +02:00
blablubbabc 1392113525 Added setting 'increment-villager-statistics' (default: false) which
controls whether opening the trading menu and trading with shopkeepers
increment minecraft's 'talked-to-villager' and 'traded-with-villager'
statistics.

Previously the talked-to-villager statistics would always get
incremented and the traded-with-villager statistic was not used.

The setting gets also tracked by bStats.
2019-08-10 00:46:32 +02:00
blablubbabc 0970d6d676 Loading the plugin before GriefPrevention in order to ensure that our
listeners run before those of GP (which listen on LOWEST priority as
well).
2019-08-08 23:43:29 +02:00
blablubbabc 4dbc7b5a7c Formatting. 2019-08-01 21:49:19 +02:00
blablubbabc 165a7eb014 Added discord server link. 2019-08-01 21:48:26 +02:00
blablubbabc 01cd4f1260 Some entity attributes are setup prior to entity spawning now (such as
metadata, non-persist flag and name (if it has/uses one)).

This should help other plugins to identify Shopkeeper entities during
spawning.
2019-07-28 03:27:20 +02:00
blablubbabc 59663f36b9 Printing entity counts of the chunk when shopkeeper spawning fails. 2019-07-27 18:39:48 +02:00
blablubbabc 39f9b27b20 Also print success state. 2019-07-26 07:03:26 +02:00