Commit Graph

702 Commits

Author SHA1 Message Date
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
Andreas Troelsen
99fc508e1f Remove the test/ folder from .gitignore.
Not quite sure why this was ever in here, but it basically prevents us from having tests, which is terrible.
2017-11-19 20:19:35 +01:00
Andreas Troelsen
d1ad24b487 Use the Things API for entry fees and class prices.
While it doesn't really make sense to have class prices be a Thing (or maybe it does?), this does get rid of the dirty "ItemStacks wit ID -29" hack for economy money, which will eventually break, when the upstream int-based ID API breaks.
2017-11-19 20:19:35 +01:00
Andreas Troelsen
2c96122e7d Allow ThingParsers to throw exceptions on invalid input instead of expecting them to return null.
This allows for a much more well-defined, fail-fast process, where a parser can abort on valid prefix but invalid input.
2017-11-19 20:19:35 +01:00
Andreas Troelsen
ea73256749 Implement the Things API for rewards (including boss wave rewards). 2017-11-19 20:19:25 +01:00
Andreas Troelsen
aecdac7b39 Add Things API.
With this commit, the Things API is introduced to the code base, but it is not yet used. It introduces the building blocks for an extensible architecture that supports custom parsers and custom "things". This should allow other developers simple, yet powerful hooks into the way MobArena handles class "equipment" and rewards. The basic skeleton includes parsers for ItemStacks and economy money, so it should be interchangeable with the current inner workings of the plugin.

The commit also adds an overload to the ItemParser that allows for a the method to fail silently. This is necessary to avoid false negatives in the log in case the ItemStackThingParser fails but a different parser succeeds.
2017-11-19 18:06:45 +01:00
garbagemule
8d61810dae
Add build status to README.md 2017-11-19 17:17:31 +01:00
Justin W. Flory
96d11ee19f Add TravisCI config to test code against OpenJDK 7, OracleJDK 8 2017-11-19 17:12:33 +01:00
Andreas Troelsen
c83cc3ede9 Add MagicSpells to the lib/ folder.
MagicSpells is not available in the maven repositories, so we'll just include the jar file for now.
2017-11-19 17:07:00 +01:00
Andreas Troelsen
03273ae797 Remove the lib/ folder from .gitignore.
The purpose of this is to actually commit to version control the jar(s) necessary to compile. It's not a best practice whatsoever, but if we can commit gradle wrappers, we can commit hard-to-incorporate binary dependencies.

As a nice side effect, it should be possible to run some basic CI tooling on the repository.
2017-11-19 17:06:01 +01:00
Justin W. Flory
36d6c7f6d7 Add issue, pull request templates 2017-11-19 16:48:40 +01:00
Andreas Troelsen
3b82cf12a4 Grant 'after' rewards when the next wave is about to spawn. Fixes #393 2017-10-09 23:57:02 +02:00
Andreas Troelsen
5d1ec8eb56 Guard against null messages in Messenger. Fixes #391 2017-10-09 23:49:47 +02:00
Andreas Troelsen
228923dab6 Bump version to 0.98.2. 2017-06-05 00:28:37 +02:00
Andreas Troelsen
6bbc9b55cf Don't rely on the Obsidian Bomb explosion to clear the dropped block item. Fixes #379 2017-05-29 09:19:04 +02:00
garbagemule
d58ec23daf Merge pull request #377 from elBukkit/IgnoreCancelledDropEvents
Ignore cancelled PlayerDropItemEvent events
2017-05-29 09:07:11 +02:00
Nathan Wolf
d6ec23025a Ignore cancelled PlayerDropItemEvent events 2017-05-24 16:57:52 -07:00
Andreas Troelsen
9bb7bc1f11 Replace some deprecated API calls with non-deprecated alternatives.
This commit does not fix all deprecated API problems, but deals with some of the most straightforward ones.
2017-05-20 22:18:06 +02:00
Andreas Troelsen
574a4fdb5f Use Reader-based load() method on YamlConfiguration instead of the deprecated InputStream-based method. Fixes #374
This is necessary because the InputStream-based method is removed in 1.12.
2017-05-20 21:33:04 +02:00
Andreas Troelsen
1da7b564d1 Remove unnecessary access modifiers on interface methods. 2017-03-13 21:32:25 +01:00
Andreas Troelsen
e988f5697c Remove unnecessary casts (and superfluous exceptions in throws clauses). 2017-03-13 21:31:16 +01:00
Andreas Troelsen
92e36da1f5 Remove unnecessary access modifiers on enum constructors. 2017-03-13 21:25:53 +01:00
Andreas Troelsen
0eeed4ff01 Embrace Java 7's diamond operator project-wide. 2017-03-13 21:23:24 +01:00
Andreas Troelsen
98d3cf0245 Only allows mobs to target each other if infighting is enabled. Fixes #364 2017-03-13 21:12:16 +01:00
Andreas Troelsen
da094e0f57 Optimize imports on all project files.
Big commit, no functional changes ¯\_(ツ)_/¯
2017-03-13 20:47:48 +01:00
Andreas Troelsen
a8b62623e8 Don't give pets and mounts to players who bring their own items.
Bringing a full stack of bones will no longer result in a full pack of wolves.
2017-03-12 21:42:57 +01:00
Andreas Troelsen
991a0ced67 Rewrite README. 2017-03-12 12:17:01 +01:00
Andreas Troelsen
50b929c4e4 Bump version to 0.98.1. 2017-03-11 16:39:37 +01:00
Andreas Troelsen
ac806f967f Remove Metrics.
Turns out this thing isn't even online anymore. Let's get rid of it.
2017-03-11 15:42:11 +01:00