Commit Graph

780 Commits

Author SHA1 Message Date
Andreas Troelsen
cc015f4e9a Log missing Vault/economy plugin during parsing of money things.
Changes the "Vault was not found" message in Vault setup to INFO instead of WARNING, because this configuration isn't actually necessarily a warning sign. Parsing a money thing with no economy is, however. MoneyThingParser logs at ERROR level if Vault or an economy plugin isn't found, but a money thing is parsed.
2018-05-13 17:43:13 +02:00
Andreas Troelsen
3d7a9ff9d2 Update to Mockito 2.18.3.
This also swaps out the dependency on mockito-all with mockito-core, which is actually maintained. The purpose of updating is to allow for new Mockito features, such as mocking final methods, which happens due to the test resource org.mockito.plugins.MockMaker.
2018-05-13 16:44:53 +02:00
Andreas Troelsen
ce392bddc3 Don't depend directly on Vault in MoneyThingParser.
It turns out that the method reference on MobArena#getEconomy() in ThingManager is a tight enough dependency on Vault's Economy interface that it results in a NoClassDefFoundError if Vault isn't present.

By resorting to a more "naive" approach of resolving the Economy instance from the main plugin class on every parse call in MoneyThingParser, the NoClassDefFoundError is avoided along with the load/enable ordering issue that was fixed with the lazy-fetching in commit 2fcb20b2ae.

This reverts 2fcb20b2ae and partly 4c34a183c7.

Fixes #463
2018-05-12 13:06:15 +02:00
Andreas Troelsen
8dbee5d4b5 Bump version to 0.100.2. 2018-05-04 21:16:38 +02:00
Andreas Troelsen
e0b6cc8992 Limit refunds to lobby players.
If the arena has already started, there is no reason why a leaver should have a refund. It's also a douchey move because your buddies in the arena will have a harder time after you leave them for dead.
2018-05-04 20:58:30 +02:00
Andreas Troelsen
5ac83b6898 Move entry fee refund to after join/leave rollback.
This moves the refunding of the entry fee to after the join/leave process for the player has been rolled back, i.e. after the inventory is restored. Before this change, the refund would happen before restoring the player's inventory, which resulted in the refund getting overwritten.
2018-05-04 20:54:12 +02:00
Andreas Troelsen
7aad81e33f Remove logging of successful join/leave steps.
This was mainly left in for debugging purposes, but it creates a bit too much spam that isn't really informative or helpful in any way, since the exception reveals the failed step anyway.
2018-05-04 03:53:09 +02:00
Andreas Troelsen
dd95e16881 Refactor entry fee logic.
This commit swaps out the naive call to takeFee with a more robust approach that actually checks the result. If it fails, the player doesn't join.

It also refactors takeFee so that it will refund any already taken parts of the entry fee if one of the parts fails.
2018-05-04 03:52:07 +02:00
Andreas Troelsen
866c928b0b Remember to take the entry fee.
The takeFee call was accidentally left out in the join/leave refactor (this commit: b1c6b61827).
2018-05-04 03:49:30 +02:00
Andreas Troelsen
2fcb20b2ae Lazy load Economy reference in MoneyThingParser.
The eager loading results in nothing but nulls because ThingManager (and, by proxy, MoneyThingParser) is instantiated on load, while the Economy provider from Vault is fetched on enable.

The bug was introduced with 4c34a183c7.

This fixes #451
2018-05-04 03:16:19 +02:00
Andreas Troelsen
8013be1724 Quote the project version in plugin.yml
MobArena has been on version 0.9x for so long that it just never was an issue that the version string was unquoted until now. Because SnakeYAML parses the string as a number, 0.100 becomes 0.1, which means the version string gets parsed into a 0 and a 1, which is less than 0 and 99 (previous version).

This should fix that problem for good.
2018-05-03 01:12:17 +02:00
Andreas Troelsen
fa435946eb Bump version to 0.100.1. 2018-05-02 20:14:29 +02:00
Hailey Loralyn
780883fce7 Add boss wave on-kill announcements
This commit adds two new announcements for use in boss waves:

- wave-boss-killed to announce who killed the boss
- wave-boss-reward-earned to notify the killer of the boss reward, if any

Fixes #428
2018-05-02 18:10:56 +02:00
Andreas Troelsen
3f3d611731 Allow lobby players to warp in-region.
Historically, we've seen plugins try to "auto-correct" the falling-through-the-world bug in Minecraft when chunks load too slowly. The plugins often solve this by force-warping until the player is stable, and blocking those teleport events are going to cause heavy "not allowed" spam.
2018-05-02 00:48:33 +02:00
Andreas Troelsen
4d174993ff Remember to grant the boss reward.
This slipped through the cracks in the ItemStack -> Thing refactor.
2018-05-02 00:45:51 +02:00
Andreas Troelsen
b1c6b61827 Refactor the join/leave process.
Note that this commit makes breaking changes to the Arena interface and completely changes the responsibility of the InventoryManager.

The join/leave process is replaced with an implementation of the Command Pattern, where every step of the process (e.g. teleport to lobby, change gamemode to survival, reset health, etc.) is realized as an implementation of the new Step interface, which has "run" and "undo" operations. The "run" operation takes a snapshot of a specific part of the player's state and then resets it. The "undo" operation restores the snapshot.

Step groupings are arranged in two factory classes, PlayerJoinArena and PlayerSpecArena, which realize, respectively, the join and spectate processes. Each instance of ArenaImpl instantiates groupings for its own context, and a grouping is invoked as one unit when a player joins or spectates an arena, and rolled back when a player leaves.

As a result of a more stringent process, some things are now a little different than before:

- Setting spectate-on-death to true effectively results in /ma leave followed by /ma spec. This makes the player/arena state a little more predictable and well-defined.
- Using exit warps will result in the player leaving to their entry point and then being teleported to the exit warp. This means the exit warp doesn't have any effect on the rest of the restoration process, as it effectively happens "post leave".

This finally fixes #423.
2018-05-02 00:38:43 +02:00
Andreas Troelsen
208a43262e Rewrite "Getting Help" section in README.
The section now includes the Discord instant invite.
2018-04-27 16:53:40 +02:00
Andreas Troelsen
860bf98e6b Add "Contributing" section to README.
This replaces the "Bugs and Suggestions" section.
2018-04-27 16:49:31 +02:00
Andreas Troelsen
f097bc8e84 Add contributing guidelines.
The goal of the contributing guidelines is to give contributors some
concrete dos and don'ts to work by, effectively making it easier on
everybody involved.
2018-04-27 16:37:07 +02:00
Andreas Troelsen
036a91f237 Remove old, borken LICENSE.md file
This doesn't actually change MobArena's license, it just removes the now
unused Markdown file.
2018-04-27 16:32:30 +02:00
garbagemule
41e8bbcfb8
Add LICENSE
This just adds the GPLv3 license file via github instead of the borken markdown one currently in the repository.
2018-04-27 16:32:02 +02:00
Hailey Loralyn
aaafba1905 Ignore Case when looking up arenas by name.
This makes commands case insensitive, e.g. /ma join. Note that arenas with the same name but different casing are considered the same arena, and one of them will be ignored during config-file parsing.
2018-04-27 13:37:03 +02:00
Andreas Troelsen
8d9764d8e9 Take offhand into account with TNT auto-ignite.
It turns out that the Inventory#removeItem(ItemStack) method doesn't actually work for items held in the offhand. This commit changes the behavior so it simply decrements the ItemStack amount for the item held during the block place. Note that going from 1 to 0 will result in an air stack, which will just disappear from the inventory.

Fixes #429
2018-04-26 20:02:33 +02:00
Andreas Troelsen
4b0b40f9b1 Rewrite the tab finding logic.
Replaces the hideous StringBuilder code with a normal String, and the BufferedReader with a basic Java NIO readAllLines(), which also takes care of the eye sore that is the finally clause with a nested try-catch.
2018-04-26 19:40:02 +02:00
Andreas Troelsen
4c34a183c7 Move Economy logic out of main plugin class and into MoneyThing.
This means that MoneyThingParser now needs to pass along an Economy instance instead of a MobArena instance, which makes the dependency a little more focused and reasonable.

Also adds MoneyThingParser tests.
2018-04-26 19:07:15 +02:00
Andreas Troelsen
d87d6ad2e9 Remove obsolete economy methods in main plugin class.
These were made obsolete when the special ItemStack type ID of -29 was refactored away.
2018-04-26 18:37:18 +02:00
Andreas Troelsen
96af679237 Remove obsolete permissions checking on main plugin class.
Originally, the permissions checking was implemented with a dependency on various permissions plugins, but since the introduction of SuperPerms, it hasn't been needed, and this residue is safe to remove.
2018-04-26 18:31:51 +02:00
Andreas Troelsen
94d198c4d0 Use implicit permissions checks for classes and arenas.
Removes the dynamic registration of permissions for classes and arenas.

This means that it is no longer enough to just check whether a Player.hasPermission("mobarena.classes.Knight"), but we also need to check if the Player.isPermissionSet("mobarena.classes.Knight"), which it won't be by default.

To make the stringly typed parts of this dynamic permissions checking more focused, ArenaClass and Arena now both have hasPermission(Player) methods, so the actual permissions checking happens on the objects themselves, rather than from the caller of these methods.
2018-04-26 18:29:25 +02:00
Andreas Troelsen
31aa4c15a1 Guard against teleporting back to the arena on death.
The /back command in Essentials - and similar commands from other plugins that allow you to warp back to your location of death - makes it possible to re-enter the arena after dying.

This commit builds upon the "leaving players" of commit 02f75d0e7f and introduces a more general notion of players being "moved". The arena is "moving" a player if the player is being teleported somewhere by MobArena (to any arena warp), and in this case, all teleports of a player are permitted. This takes care of the cases where MobArena "might be doing it". The rest of the cases are due to commands, plugins, ender pearls, etc., and they are a little easier to deal with separately. The new logic is more straightforward and should prevent most exploits and permit most legit warp cases.

This (hopefully) fixes #313.
2018-04-24 14:15:10 +02:00
Andreas Troelsen
37de1e66e9 Use Things API for class armor.
Swaps out the hard dependecy on ItemStack for class armor, such that the ThingManager - and thus every ThingParser registered within - has a chance at providing "armor" for a class.

To distinguish armor from items, ArenaMasterImpl prepends "armor:" or slot-specific prefixes to these values before passing them to the ThingManager. This makes it possible to distinguish between items and armor on the thing parser end if applicable - it doesn't make sense for money and command parsers, but they will just end up skipping these values.

The ItemStackThingParser is given a bit of an overhaul. It now depends internally on ItemStack parsers, which can be registered via the ThingManager. This allows custom plugins to hook into the ItemStack-specific part of the ItemStackThingParser to avoid having to duplicate code. Plugins that just want to provide ItemStacks can use this parser approach, and plugins that want to provide more abstract Things can use the Thing parser approach.
2018-04-24 14:07:42 +02:00
Andreas Troelsen
8014420c1b Use Things API for class items.
Swaps out the hard dependecy on ItemStack for class items (not armor), such that the ThingManager - and thus every ThingParser registered within - has a chance at providing "items" for a class.

Armor is not handled in this commit, because it appears to be quite a bit of extra work, and the "equippable" nature of armor needs to be handled differently than regular inventory items.

The getLogo() method on ArenaClass is removed, because it is no longer used (internally at least). It is residue from the old Spout support.
2018-04-24 13:52:40 +02:00
Andreas Troelsen
5d2881383f Guard against exceptions when setting scoreboards for disconnecting players.
Turns out that a player who disconnects while in the arena is actually still online if you ask the Player object. The setScoreboard() javadoc specifically says it throws an IllegalStateException in that case, so we can just catch and swallow it.

It's unclear what the state of the player's scoreboard is when they rejoin the server, but a borken scoreboard is better than a rogue exception.
2018-04-23 11:53:24 +02:00
Andreas Troelsen
99f57b7128 Ban certain items from the "My Items" class.
This commit removes certain items from the in-arena inventories of players who choose the "My Items" class:

- Ender chests allow players to smuggle stuff out of arenas
- Ender pearls can be used to warp to unintended spots, and to build ender chests
- Shulker boxes can carry any items - including ender chests
- Shulker shells can be used to build shulker boxes

At the end of the day, ender chests are the bad seed. The rest are just to prevent ender chests from making appearances.
2018-04-23 02:07:00 +02:00
Andreas Troelsen
02f75d0e7f Prevent infinite loops due to PlayerDropItemEvent from /give command.
Apparently, the /give command will drop an item "as" the target player, resulting in the player picking up the item if there is room in their inventory. This triggers a PlayerDropItemEvent, which MobArena catches and tries to cancel if the target player is in an arena. Furthermore, if the player is a spectator outside of the arena region, MobArena will force the player to leave the arena. This triggers the reward granting logic, so using the /give command as a reward has the potential of causing an infinite loop.

This commit introduces the idea of "leaving players", i.e. players in the process of leaving the arena. In the event of a dropped item from a player who is currently leaving an arena, the PlayerDropItemEvent is ignored, because it is assumed to be from the /give command. Note that this doesn't actually prevent normal PlayerDropItemEvents from causing a forced leave, since the player won't be in the process of leaving at that specific point.
2018-04-23 00:51:14 +02:00
Andreas Troelsen
e4d919cf3e Add caching and conditional saving to ConfigUtils.
This commit changes the naive behavior of the ConfigUtils methods addIfEmpty() and addMissingRemoveObsolete(). Instead of an almost guaranteed config-file write on every invocation of either method, writes only happen if the loaded configuration changes. The excessive writes result in long config reload times, and this change fixes that, effectively fixing the second part of #435.

To further the performance boost, the resource reads are cached in a map - this turns out to not be an issue for server plugin reloads, as a new ClassLoader instance is used to load the new set of plugins.
2018-04-22 22:20:20 +02:00
Andreas Troelsen
b1634f9460 Return early from forceEnd() if there are no players in the arena.
This means that the cleanup code will only run if there are players in the lobby, arena, or spectator area. This fixes the first part of #435 where the cleanup code is taking too long for large/many arenas.

Originally, the force end command was meant as a way to circumvent any condition keeping players from leaving the arena and cleaning it up. In retrospect, the main reason for using force end is to "get people out of there", but since there's plenty of stuff that can go wrong when a player leaves, this isn't really that helpful, as exceptions will just cause the command to break at the same point anyway.
2018-04-22 20:12:31 +02:00
Andreas Troelsen
a91c5e7a74 Build against Java 8.
Java 7 is EOL, and according to the metrics, this change affects less than 1% of MobArena servers.

Fixes #404, closes #410.
2018-04-17 18:18:05 +02:00
Nathan Wolf
8b40f415be Use ItemStack display name when describing an ItemStackThing (#441)
Use ItemStack display name in ItemStackThing (if available).

This means that named items will appear in the rewards list with their name rather than the ItemStack type. This is useful for "tokens" type items.

Note that named items are still not supported by the built-in item parser, so this commit only affects ItemStackThings created by custom parsers (for now).
2018-04-17 03:10:15 +02:00
Justin W. Flory
c80b76e732 Update "Item and reward syntax" documentation (see full commit)
This commit updates the "Item and reward syntax" documentation.

* Follows RST document style guide
* Uses active voice / minor edits
* Reorganize structure / flow
2018-01-15 22:05:05 +01:00
Justin W. Flory
e85696138c Make issue template less text-heavy in comments, add documentation as option 2017-12-05 01:12:00 +01:00
Justin W. Flory
39d72543fd Use internal links in lists, note sign creation message, minor edits 2017-12-03 22:36:06 +01:00
Justin W. Flory
ed5bb7684b Update Arena Setup documentation
This commit updates the Arena Setup documentation.

* Follows RST document style guide
* Uses active voice / minor edits
* Improve document organization

I also renamed the wave-formulas.rst file since it had a typo, and was
referenced in the Arena Setup document.
2017-12-03 22:36:06 +01:00
Justin W. Flory
f30e6ba974 Update announcements documentation (see full commit)
This commit does the following:

* Uses ReStructuredText style guide for the announcements documentation
* Uses active voice / minor edits
* Adds examples

This was tested locally in a development environment.
2017-12-03 19:56:33 +01:00
Justin W. Flory
e4a0783258 Add documentation as a contribution type to PR template 2017-12-03 19:45:15 +01:00
Justin W. Flory
c7a415dbf8
Use sphinx_rtd_theme for HTML theme 2017-12-02 19:16:20 -05:00
Justin W. Flory
79c607f96d
Convert all GitHub wiki pages into ReStructuredText documents, set up ReadTheDocs 2017-12-02 19:16:17 -05:00
Justin W. Flory
48ae60e070
Update .gitignore for Python virtualenvs (for docs) 2017-11-29 14:06:51 -05:00
Andreas Troelsen
9ccb13773b Bump version to 0.99.1. 2017-11-19 23:02:46 +01:00
Andreas Troelsen
56e83bdaf3 Implement support for commands as things.
With CommandThing and its parser, it is now possible to use commands anywhere a thing can be used. Commands are invoked as the console/server, and they support a single variable, the name of the recipient player.

Commands are give-only, meaning they will fail to be "taken" from players, and they cannot be "held" either. The idea of commands as things basically only makes sense in the context of rewards.
2017-11-19 20:19:36 +01:00
Andreas Troelsen
6e57c018b5 Add a few tests for ThingManager. 2017-11-19 20:19:36 +01:00