Commit Graph

775 Commits

Author SHA1 Message Date
Andreas Troelsen cd1f7ff797 Use new BlockData API for non-linked class chests.
Similar to the previous commit about leaderboards, this commit fixes the crash caused by using the MaterialData API on Minecraft 1.14 servers.

Fixes #546
2019-07-20 22:56:40 +02:00
Andreas Troelsen cc0a2f30b4 Use new BlockData API for Leaderboards.
This commit fixes a bug on Minecraft 1.14 servers where leaderboards would cause a NullPointerException due to the MaterialData API being broken. Instead, we now use the new BlockData API, and everything is back to normal.

Fixes #536
2019-07-20 22:55:49 +02:00
Andreas Troelsen 996a592023 Make all "damageable" items unbreakable.
This commit changes how the unbreakable setting works by just assuming that everything that is "damageable" (implements the Damageable interface) needs to be set as unbreakable. This means that the entire weapons/armor collection in ArenaClass is obsolete, and all of the checking is contained in ArenaImpl.

Fixes #544
2019-07-20 22:47:00 +02:00
Andreas Troelsen a3004d6403 Give stone swords to wither skeletons on spawn.
Fixes #538
2019-07-20 22:39:22 +02:00
Andreas Troelsen 7317c64678 Use max health value instead of base value in SetHealth step.
This commit changes the SetHealth step such that it uses the player's own value for max health rather than the generic base value. As a result, players who join holding items that lower their max health will be missing health as soon as they join the lobby. But because food levels are maxed and locked, the health will quickly regenerate.

Unfortunately, players who join with a higher health value than the base max health value will have their health capped to the base max health value on the way out of the arena. This was also the case before this commit, but it is worth mentioning again for completeness.

These odd side effects are currently "necessary" because the effects of items that change max health values for players don't take immediate effect in the same tick as they are added/removed, so because MobArena's join sequence is synchronous, we can't feasibly "get it right".

Fixes #545
2019-07-20 22:37:23 +02:00
Andreas Troelsen 88ddbe5ac6 Lock food level for players in the lobby or spectator area.
There is no reason why food should be a thing in the lobby or spectator area. This commit effectively disables it for players in those places/states, while retaining the in-arena conditional logic based on the config-file setting.

Fixes #514
2019-07-20 21:40:24 +02:00
Andreas Troelsen 4f548e08a6 Use a blacklist for the server version check.
The whitelisting approach works well for the legacy builds, because the
version landscape doesn't change with those. However, the main build on
the master branch will not run on a server version other than 1.13, so
come 1.14, MobArena will be broken.

This commit fixes this problem by changing to a blacklisting approach
for the main build on the master branch. Checking for versions that the
build *can't* run on brings back MobArena's old resilience to version
changes on the Minecraft side of things.
2019-04-16 12:38:19 +02:00
Andreas Troelsen 93af93d5a0 Use attribute base value instead of 20 when setting player health.
The previous hardcoded value of `20.0` works in most cases, but if a server uses a base health higher than 20, players don't get a full heal. Worse, if the base health is lower than 20, MobArena crashes when it tries to set the health to 20, which is now out of range.

This commit introduces the Attribute enum to MobArena's code base and uses it to get the base value for player max health. This should fix the aforementioned issues.

Fixes #513
2019-02-16 17:41:55 +01:00
Andreas Troelsen afcc526a71 Relocate `mobarena.admin.teleport` permission check.
Instead of explicitly ALLOW'ing a teleport if a player has the permission, we let the teleport handler logic run its course. If an arena explicitly REJECTs the teleport, we need to cancel the event, but the permission now overrides that behavior. This means that only in the case of an impending event cancellation, the permission kicks in.

This is important, because the permission is supposed to override the decision to cancel, rather than drive the decision to uncancel. With this change, MobArena never uncancels something it wouldn't have uncancelled otherwise, meaning it won't interfere with teleports outside of its own context, and thus won't interfere with other plugins.

Fixes #515, closes #516

Thanks to @minoneer for the bug report and pull request that this code
was based upon!
2019-02-16 17:40:45 +01:00
Andreas Troelsen fc8debca29 Clone ItemStack before adding to player inventory.
Spigot is at it again with another breaking change to the API where the
JavaDocs have been retrofitted to match the new, ancient way of writing
software.

The addItem and removeItem methods originally just added or removed
whatever they could when called, and returned a map of items that failed
due to lack of space/items. Now, with the breaking API change, these
methods actually *mutate their arguments* - a practice that has been
heavily discouraged for decades in modern software development, and
something you usually only see in C these days. This change, like many
others in the same vein, show the complete recklessness, incompetence,
and lack of awareness from an otherwise talented team of developers.
Hopefully, they will continue to hone their skills so that we can
eventually have a stable API again.
2019-02-03 14:34:37 +01:00
Andreas Troelsen 0e037b2f72 Don't change player flySpeed on join/spec.
From a purist standpoint, the flySpeed tag should never be messed with
in MobArena, because simply turning off flight should be enough. It is
likely that the flySpeed tag was originally included to cull "cheaters"
who somehow managed to activate flight in the arena anyway, but this
isn't really MobArena's responsibility and can very probably be handled
by other means of cheat prevention in WorldGuard regions or the like.

By not touching the flySpeed tag, it makes it much easier for server
owners to recover from crashes where the leave steps aren't executed,
leaving players "locked in the air" when they try to fly.

Closes #509 since this "fix" was the reason that feature request was made.
2019-02-03 14:32:28 +01:00
Andreas Troelsen 7bc6cf2800 Make commands case insensitive.
Note that this doesn't make the arguments for commands case insensitive. Each command is still responsible for lowercasing their arguments if it makes sense for them to do so.

This closes #446.
2018-12-31 14:50:19 +01:00
Andreas Troelsen 74a7388701 Make enchantments case insensitive.
Lowercasing the enchantment string before feeding it to the Bukkit API makes the enchantments a little more "copy/paste proof" when grabbing the uppercased names from the JavaDocs/Minecraft wiki.
2018-12-31 14:40:54 +01:00
Andreas Troelsen 5e7cb2a82b Allow class pets to teleport to their owners.
This closes #497.
2018-12-31 14:20:27 +01:00
Andreas Troelsen 624b87f4d3 Prevent spectators from taking damage at all times.
Spectating is possible both during and before/after arena sessions. This means that an early return from the entity damage cancellation logic when the arena isn't running is going to allow damage to go through to spectators of non-running arenas, which means they can die. By simply removing the early return (and placing it in the one branch that actually requires it explicitly), spectators should no longer be able to take damage.

This fixes #502.
2018-12-30 14:05:02 +01:00
Andreas Troelsen 399b228999 Use unbreakable item meta flag for unbreakable weapons and armor.
This changes how unbreakable items work in MobArena. It removes the legacy "repair logic" and replaces it with the item meta unbreakable flag. This approach should work all the same, except now if weapons and armor in class chests have special durability values, these are preserved in the cloning.

This should make MobArena compatible with plugins that depend on special durability values, such as QualityArmory.
2018-11-18 16:36:19 +01:00
Andreas Troelsen 32499dbe11 Use unbreakable item meta flag for unbreakable weapons and armor.
This changes how unbreakable items work in MobArena. It removes the legacy "repair logic" and replaces it with the item meta unbreakable flag. This approach should work all the same, except now if weapons and armor in class chests have special durability values, these are preserved in the cloning.

This should make MobArena compatible with plugins that depend on special durability values, such as QualityArmory.
2018-09-23 15:44:54 +02:00
Sait™ 6a8c6a9741 Grant permission for /ma ready by default
This makes the ready command consistent with the rest of the sane defaults as well as with the ready block, which requires no permissions.
2018-08-31 19:46:36 +02:00
Andreas Troelsen c546641c7b Start the join-interrupt-timer from the spectator area.
Following the changes in 266104d0a1, this commit gathers the leave-then-join logic and handles it in one fell swoop when joining from the spectator area. This means that the timer will start, and when it runs out, the player leaves the current arena (if any), and then joins.

There should be no issues with overlapping timers or anything like that, since the lookup happens when the time is up, not before the timer is started.
2018-08-28 21:30:45 +02:00
Andreas Troelsen 266104d0a1 Re-allow joining from spectator areas.
Commit 924a419b47 made it impossible to join an arena from a spectator area because the playerLeave method call in JoinCommand was removed. The call is re-introduced in this commit along with similar logic in InvokesSignAction. This means that a spectating player can now join arenas as if they weren't spectating, rather than having to first leave the arena they are spectating.
2018-08-24 19:27:21 +02:00
Andreas Troelsen 934eb2d8cc Build against Bukkit API for Minecraft 1.13.
This very likely introduces a few bugs and breaks some functionality, but at least we're compiling...
2018-08-19 21:05:24 +02:00
Andreas Troelsen 754eb156d1 Make SheepBouncer logic cancellable.
Following the changes in 96c1f18517, this commit makes SheepBouncer cancellable for the same reasons as outlined in the MASpawnThread commit.
2018-08-19 20:48:04 +02:00
Andreas Troelsen 96c1f18517 Make MASpawnThread logic cancellable.
This commit changes how MASpawnThread is started. Instead of simply scheduling a task and letting it run whenever, we now explicitly tell it to stop when the arena ends. This matters, because if the scheduled task does not get cancelled, it will run at the scheduled time. MASpawnThread's run() method has an early return to stop whenever the arena isn't running, but with unlucky timing, it's possible to start a new arena session before the task runs again, meaning the same MASpawnThread keeps scheduling itself on the previous scheduling loop.

Instead of this whacky approach, we now specifically have MASpawnThread track its own BukkitTask. Upon arena start, we instantiate a new MASpawnThread and call its start() method, which in turn schedules itself and stores a reference to the associated BukkitTask. Upon arena end, we call the MASpawnThread's stop() method, which explicitly calls the BukkitTask's cancel() method, effectively stopping/unscheduling the task.

This fixes the (very) long-standing "double wave spawner" bug that we haven't been able to reproduce for so long. Hooray!
2018-08-19 20:47:25 +02:00
Andreas Troelsen fc51c5eff5 Clean up IntelliJ's overzealous refactoring of the word "reload"...
The command we want people to type is /ma reload, not /ma load. This is likely splash damage from a Rename refactoring action in IntelliJ.
2018-08-19 11:06:17 +02:00
Andreas Troelsen 220197b5db Bring keep-exp per-arena setting back.
This setting was removed a long time ago, likely by "happy mistake" in a larger refactoring.

When enabled, players are granted any collected experience during the arena session as a reward when they die or reach the final wave of the arena. Note that deliberately leaving the arena is not included here, because "leaving" an arena is a highly ambiguous and conditional concept at the time of this commit. Figuring out when and how the experience reward should be added is complicated, and unless someone puts in a request for it, I think it's enough that the "legitimate" reasons for getting the experience (honorable death and reaching the final wave) are covered.

Closes #485
2018-08-19 11:06:17 +02:00
Andreas Troelsen fbb5fe7c4a Include total experience in SetExperience step.
It turns out that experience in Minecraft is split out on a couple of different variables, and they are only loosely coupled.

Total experience, level, and level progress are three completely different variables that can be manipulated individually. This means that while 10 experience points from level 0 should bring you up to level 1 with a third of the experience bar full (level 0 to 1 takes 7 points, level 1 to 2 takes 9 points), simply setting the total points value to 10 won't automatically level you up. Using the Player#giveExp(int) method will, however, work this way.
2018-08-19 11:06:02 +02:00
Sait™ 977df0b9f4 Add /ma ready
This commit adds a new command, /ma ready (/ma rdy for short), as an alternative to the iron block for readying up after picking a class.

Note that this conflicts with the shorthand for /ma notready, which no longer triggers on the word "ready", but only on "notready".
2018-08-19 11:00:19 +02:00
Andreas Troelsen 548d8c7e4f Allow armor stands in arenas and lobbies.
This commit adds an event handler for the PlayerArmorStandManipulateEvent and cancels it if the arena protection is on, we aren't in edit mode, and the region contains the armor stand. The same logic applies to the armor stand damage event.
2018-08-11 00:16:21 +02:00
Andreas Troelsen 51fa78acd9 Change the fallback command error message.
This is a little less panicky, and it doesn't reference IRC (which is basically dead).
2018-08-10 23:23:34 +02:00
Andreas Troelsen 1fc6c5b8b9 Use an alias instead of two separate commands in plugin.yml 2018-08-10 23:23:33 +02:00
Andreas Troelsen 170dc2b122 Remove trailing whitespaces in command handler. 2018-08-10 23:23:33 +02:00
Andreas Troelsen 8d91598b21 Remove trailing whitespaces in main plugin class. 2018-08-10 23:23:33 +02:00
Andreas Troelsen a1e802c6f0 Minor cleanup in ArenaMaster.
Removes unused imports and fields, trailing whitespace.
2018-08-10 23:23:33 +02:00
Andreas Troelsen 2081405d3b Refactor startup logic.
This commit re-implements and rearranges a lot of the logic in the main plugin class. It also removes the ConfigCommand class and moves its functionality into the CommandHandler to allow for reloads to be a bit more special than normal commands.

In the refactoring of the main class, the startup logic is broken up into two phases, setup and (re)load:

- In the setup phase, we create the data folder, and the command handler, config serializer(s), plugin integrations, boss abilities, the global event listener, and metrics are initialized. The ArenaMaster is instantiated, but it isn't initialized. These are things that need to be set up just once and don't change on reloads.

- In the (re)load phase, the config-file is loaded from disk, the global messenger is instantiated, the arena master is initialized (loads settings, classes, and arenas), the announcements file is loaded from disk along with the sign data/templates. These are things that we want to be reloadable.

If anything goes wrong during these phases, we store the exception thrown. This puts MobArena into a state where it prints the exception message to anyone who types a non-reload MobArena command to bring attention to the error so it can be fixed.
2018-08-10 23:23:30 +02:00
Andreas Troelsen dc25a38d98 Throw ConfigErrors when pet items are invalid. 2018-08-10 21:55:22 +02:00
Andreas Troelsen beb4269525 Remove all of the obsolete and commented out code in WaveUtils. 2018-08-06 01:25:21 +02:00
Andreas Troelsen 13e3c180e5 Make the class items node consistent with the rest.
Supposedly, this doesn't actually do much, but the code now looks like the rest of the "string or string list" parsing.
2018-08-06 01:23:26 +02:00
Andreas Troelsen 951e83cc55 Rework some of the wave parsing logic.
This commit is a full sweep across the WaveParser. It introduces the ConfigError exception to the WaveParser and throws it whenever something isn't right. There's quite a lot of stuff going on, but in overall:

- Errors are thrown rather than null values being returned
- Defaults are picked in lieu of explicit values when they "make sense"
- Most list-type values can now be either the default comma-separated string or a string list

Common nodes:
- Spawnpoints can now be a string list

Default waves:
- Missing or empty monsters map throws an error
- Missing wave growth defaults to medium
- Invalid wave growth throws an error

Special waves:
- Missing or empty monsters map throws an error

Swarm waves:
- Missing or empty monster node throws an error
- Missing swarm amount defaults to low
- Invalid swarm amount throws an error

Supply waves:
- Missing or empty monsters map throws an error
- Missing or empty drops node throws an error
- Invalid drop throws an error
- Drops can now be a string list

Upgrade waves:
- Missing or empty upgrades map throws an error

Boss waves:
- Missing or empty monster node throws an error
- Missing or empty boss health defaults to medium
- Invalid boss health throws an error
- Invalid ability throws an error
- Invalid drop throws an error
- Abilities and drops can now be string lists
2018-08-06 01:22:27 +02:00
Andreas Troelsen 060a395213 Guard against non-living entities in MACreature.
This should prevent runtime errors where MobArena tries to spawn non-living entities, causing arenas to get locked up.

Fixes #438
2018-08-05 23:30:03 +02:00
Andreas Troelsen cd82a89626 Rewrite ThingParser usages.
This commit changes how the ThingParser is used throughout the code base. Instead of blindly filtering out null values, we're now throwing a new InvalidThingInputString exception. This exception is caught in an outer scope that has more context. The exception is then unwrapped and rethrown as a ConfigError with the additional context. In the outermost scope of (re)loading the config-file, the ConfigError is caught and printed, and then (re)loading stops gracefully.

We still need a proper way to handle loads/reloads consistently to get rid of the default command usage message, but this is a good step towards better usability in the face of user errors.

Fixes #478
2018-08-05 23:14:01 +02:00
Andreas Troelsen 924a419b47 Add join-interrupt-timer per-arena setting.
This commit adds a new per-arena setting, join-interrupt-timer, which, when set to a positive number, will introduce a delay to the join and spec commands. During this delay, if the player takes damage or moves more than one block's distance, the command will be interrupted.

Closes #482
2018-08-05 21:17:05 +02:00
Andreas Troelsen 7a9b2f601f Add next-wave-delay per-arena setting.
This commit adds a new per-arena config-file setting, next-wave-delay. When a new wave is about to spawn, a positive next-wave-delay value will cause the spawning of the wave to be delayed by that amount of seconds, similar to how first-wave-delay delays the spawning of the first wave.

By moving all of the actual spawning logic into a new method and simply referencing that as a Runnable, we can avoid having to set weird boolean flags and re-scheduling the MASpawnThread itself.

Closes #449
2018-07-29 21:23:29 +02:00
Andreas Troelsen 6f077359c6 Add a dedicated field for wave-interval in MASpawnThread.
All of the calls to getSettings() are now contained in the constructor and reset() method. Neat.
2018-07-29 15:55:39 +02:00
Andreas Troelsen 3b024235dc Remove support for undoing autogenerated arenas.
The autogenerated arenas are backed up in a file that isn't valid in 1.13. It's also buggy, inducing a false sense of safety. Instead of trying to hack it together for 1.13, let's remove it and see if we can't live without it.
2018-07-23 01:18:05 +02:00
Andreas Troelsen 5937eb0631 Deny use of held items in the lobby.
This semi-reverts part of the change in e484583b7e.

We're now specifically denying the use of items if there are any. This doesn't cancel the interact event, but just prevents stuff like potion consumption.
2018-07-19 15:07:23 +02:00
Andreas Troelsen 85687c86b5 Prevent snow and ice from melting in arenas.
The block fade event is called when a block fades from one state to another, such as when snow melts and becomes air, or ice melts and becomes water. Cancelling it solves the issue of snow and ice melting in arenas.

Fixes #249.
2018-07-19 02:01:41 +02:00
Andreas Troelsen e484583b7e Allow right click actions in the lobby.
Originally, the right click ban was introduced to prevent issues with people blowing themselves and each other up in the lobby. The right click ban only solves this issue sometimes, so it isn't really very effective.

By removing the right click ban, it becomes possible to activate redstone stuff like buttons and levers in the lobby.

Fixes #431.
2018-07-19 00:59:34 +02:00
Andreas Troelsen 1371a90871 Remove the give-all-items flag for Upgrade waves.
The flag is almost always set to true, and when it isn't, it's either because people don't know that they have to set it, or because they only give one upgrade per class and thus don't feel the effect of it.
2018-07-05 11:29:23 +02:00
Andreas Troelsen b58964dce9 Grant class potion effects separately to make sure class chests aren't forgotten about.
This is not the proper way to solve this issue, but the refactoring needed to move the responsibility of class chest search somewhere else is a bit too much for a bug hunt.
2018-07-05 11:19:28 +02:00
Andreas Troelsen 335e3e81a6 Replace deprecated matcher in MoneyThingParserTest. 2018-07-04 02:09:54 +02:00
Andreas Troelsen 35f114959f Replace deprecated ItemStack constructor in ArenaImpl. 2018-07-04 02:05:29 +02:00
Andreas Troelsen 25dc6b577b Replace deprecated getItemInHand() calls in SetupCommand. 2018-07-04 01:57:30 +02:00
Andreas Troelsen d0eb1cc487 Remove unused InventoryUtils class.
No clue what this was for. Possibly entry fees?
2018-07-04 01:50:24 +02:00
Andreas Troelsen c21d7e9e96 Remove unused RegionSerializer class.
No idea when this was last used. Possibly before force-restore was removed.
2018-07-04 01:47:37 +02:00
Andreas Troelsen 623bfae308 Update ScoreboardManager to Java 8 lambdas and method references.
Just makes things a little bit neater.
2018-07-04 01:42:52 +02:00
Andreas Troelsen dbd04294a4 Replace deprecated calls in ScoreboardManager with proper ones.
Fixes a small portion of #406
2018-07-04 01:35:08 +02:00
Andreas Troelsen 9809e9ebc9 Remember and restore existing player scoreboards.
This introduces state in the ScoreboardManager for keeping track of the scoreboards that players have before the arena session starts, if any. Upon leaving, the scoreboards are restored.

Ideally, this change should be re-implemented as a Step of the join/leave process, but that would require opening up Arena or ScoreboardManager in ways that would probably be best handled in a rewrite of the scoreboards, so we'll leave it in ScoreboardManager for now.

Fixes #366
2018-07-04 01:25:38 +02:00
Andreas Troelsen bacfe291bf Remove obsolete hellhounds setting.
Bye bye, flaming puppies.
2018-07-03 18:22:30 +02:00
Andreas Troelsen ccf6cda59a Add support for ocelot pets.
By default, a raw fish will turn into a pet ocelot, but the item type is configurable.
2018-07-03 18:13:42 +02:00
Andreas Troelsen 63d2c552a6 Make the bone-to-pet-wolf transformation item customizable.
A new section in global-settings called pet-items is used to define pet item transformation items. By default, bones are transformed into wolves, but the item type can now be changed to support using actual bones in classes.

This refactors the pet spawning into its own class to reduce some of the massive responsibility of ArenaImpl.

This closes #467
2018-07-03 18:13:36 +02:00
Andreas Troelsen f4f74c5b87 Modernize default classes.
The default classes now use string IDs for all items, and a couple of them now have starting potion effects.
2018-07-03 15:05:03 +02:00
Andreas Troelsen b5b4fdd30a Add support for named potion types and enchantments.
In this commit, the ItemParser's behavior changes from one that requires or encourages numeric IDs for everything to one that discourages it by logging a warning that suggests using a string instead of a numeric value.

While this doesn't actually make things that much better for updating to Minecraft 1.13, the "ID nagging" hopefully increases awareness about the upcoming breaking changes.

Fixes #382
2018-07-03 14:51:54 +02:00
Andreas Troelsen fe35964b93 Remove unused import in ItemParser. 2018-07-03 01:31:28 +02:00
Andreas Troelsen 16f08ef9a0 Remove obsolete parseString methods in ItemParser.
This follows from the removal of the set class command being removed and the cascading removal of the methods in ArenaMasterImpl that referenced the parseString methods in ItemParser.
2018-07-03 01:30:59 +02:00
Andreas Troelsen e572fc3dae Remove obsolete class methods in ArenaMaster.
Following the removal of set/remove class commands in 51b4b25094, these methods are now obsolete.
2018-07-03 01:28:38 +02:00
Andreas Troelsen 51b4b25094 Remove set/remove class commands.
Similar to a88556771f.

This specific change may stir the pot a bit, since some people may rely on the set command. However, class chests solve a lot of the problems that the initial command set out to tackle, and we can probably do better in a rewrite of the command if it's missed anyway.

The removed commands render a few methods in ArenaMaster obsolete.
2018-07-03 01:27:35 +02:00
Andreas Troelsen baf709b446 Remove set class price command.
Similar to a88556771f.
2018-07-03 01:07:18 +02:00
Andreas Troelsen 691b608466 Remove obsolete class permission method in ArenaClass.
Following the removal of class permission commands in a88556771f, this method is now obsolete.
2018-07-03 01:03:32 +02:00
Andreas Troelsen cf82a3a612 Remove obsolete class permission methods in ArenaMaster.
Following the removal of class permission commands in a88556771f, these methods are now obsolete.
2018-07-03 01:02:40 +02:00
Andreas Troelsen a88556771f Remove class permission commands.
These commands solve a very, very specific problem that it's safe to assume nobody has. It's safe to assume that most config editing happens in the actual config-file, and changing class permissions is probably one of the last things people would expect to find a command for.

Removing these commands renders some methods in ArenaMaster and ArenaClass obsolete.
2018-07-03 01:00:00 +02:00
Andreas Troelsen 5699fafeb0 Add server version compatibility check.
Instead of the obscure error thrown from ArenaClass when the SHIELD enum value on Material isn't found, MobArena throws its own, more human-friendly error.

Fixes #469
2018-07-03 00:22:36 +02:00
Andreas Troelsen 650e7bbd44 Remove all players from boss bars when clearing the MonsterManager.
When the arena ends, the MonsterManager is cleared, which means that all references to health bars are lost. Before this, we remove all players from any boss bars to make sure that the boss bars don't stick to players upon dying.

Fixes #473
2018-06-25 10:30:14 +02:00
Andreas Troelsen 9d0cd8f967 Clean up the grantItems method in UpgradeWave.
The Arena parameter is no longer needed. Let's get rid of it.
2018-06-25 00:13:17 +02:00
Andreas Troelsen 0f34e1fdb7 Use Things API in upgrade waves.
This changes the upgrade waves from the local Upgrade interface to the Thing interface. This means that all Things can now be used in upgrade waves, including commands, money, potion effects, and permissions.

Unfortunately, the weapons upgrade/replace functionality has been gutted as a result of the Things API not supporting it. We could add it back in later down the road, but for now let's just see if it causes anyone any inconvenience.

Closes #468
2018-06-25 00:13:12 +02:00
Andreas Troelsen a9d0ca0828 Use the Things API for per-class permissions.
This replaces the Map<String, Boolean> approach in ArenaClass with a List<Thing> approach. This greatly simplifies how per-class permissions are handled.
2018-06-24 13:05:47 +02:00
Andreas Troelsen c1d1728144 Add support for permissions in the Things API.
This commit introduces the PermissionThing and associated parser. The parser determines the value (grant/revoke) of the permission by looking at the first character of the input string - if it is a minus (-) or caret (^), the value is false (revoke), otherwise it is true (grant). To distinguish permissions from other things, the parser requires a prefix of "perm:".
2018-06-24 13:05:38 +02:00
Andreas Troelsen 19fb748e0e Rework per-class permissions handling.
This removes the map of attachments in ArenaImpl and makes the permissions "replacement" happen via the Bukkit API's PermissionAttachmentInfo. Bukkit already keeps track of which attachments we've added to a player, so removing them is just a matter of looping through and finding those. This reduces the coupling between the Arena interface and UpgradeWave (which is the only interface that used the methods removed from the Arena interface).
2018-06-23 18:22:29 +02:00
Andreas Troelsen 96fa87a544 Remove potion effects when a player changes class via class chests.
This fixes #471
2018-06-23 17:37:42 +02:00
Andreas Troelsen ae3b394b46 Reuse removePotionEffects() in ArenaImpl.
This commit also rearranges the method, placing it closer to the cleanup methods.
2018-06-23 17:14:25 +02:00
Andreas Troelsen cbf18ff720 Guard against non-existent plugin folder.
If there isn't already a MobArena folder in the plugins folder, this line fails if we don't make sure to recurse on the folder creation.
2018-06-23 00:00:12 +02:00
Andreas Troelsen b4e16c16b3 Add newline at the end of main plugin class. 2018-06-22 23:35:13 +02:00
Andreas Troelsen b2064bf33f Add more bStats metrics.
The goal with these specific metrics is to figure out if some of the arena settings can be removed. If everyone uses the same values for these settings, there is no point in having the added complexity in the code.
2018-06-22 23:03:05 +02:00
Andreas Troelsen 2aecea401d Add support for boss health bars.
Three different types of health bars are implemented behind a basic Strategy Pattern. A new per-arena setting, boss-health-bar, can be used to configure which one of the three types (if any) of health bar should be used for bosses in the given arena:

- `boss-bar` creates a boss bar at the top of the screen as if the players were fighting an ender dragon or a wither.
- `title` uses the Chapters/Titles API in Bukkit to display the health of the boss as a "subtitle" whenever it takes damage.
- `name` sets the entitiy's health along with an optional custom name above the entity's head.
2018-06-22 00:00:05 +02:00
Andreas Troelsen c4362474a1 Rearrange methods.
This is just to group reloadAnnouncementsFile() with reloadSigns() for an attempt at better cohesion in the logical structure of the code.
2018-06-16 18:26:16 +02:00
Andreas Troelsen 2404bb478d Throw an exception if the announcements-file fails to load.
This makes errors in the announcements-file more visible, both during initial load and during reloads.
2018-06-16 18:26:16 +02:00
Andreas Troelsen a834246cbd Reload announcements when reloading the config-file.
The announcements file loading method is renamed to indicate that it's also meant for re-loading, and the access modifier is changed from private to package-private to allow ArenaMasterImpl to call it.

Closes #462
2018-06-16 18:25:57 +02:00
Andreas Troelsen 322ee0f22b Remove unused totals.yml resource.
This file is residue from the old primitive stats system that wasn't being used.
2018-06-14 00:29:17 +02:00
Andreas Troelsen 18729f092e Remove unused keep-exp arena setting.
The setting is never bound to anything in the code, so no point in keeping it around in the default settings resource.
2018-06-14 00:29:17 +02:00
Andreas Troelsen 2ca5e447c0 Add support for dedicated potion effect node in classes.
This makes it a little less awkward to add potion effects to a class, giving them their own node instead of having to "share" with the items node.
2018-06-14 00:29:17 +02:00
Andreas Troelsen a2e235e77a Add support for potion effects in the Things API.
This commit introduces the PotionEffectThing and associated parser. The parser simply delegates to the existing PotionEffectParser utility class the same way the ItemStackThing parser does it. To distinguish potion effects from other things, the parser requires a prefix of "effect:".

As with the initial Thing API commit, this commit also adds an overload to the existing parser class to avoid spamming the console with meaningless warnings.
2018-06-14 00:29:17 +02:00
Andreas Troelsen 9594bd6126 Allow potion effects on all wave types.
Boss waves already support potion effects, but with this commit, the potions node moves up as a common node, so all waves that spawn monsters (all but upgrade waves) can now spawn those monsters with a list of potion effects applied to them. It's not possible to give certain potion effects to specific monster types. All monsters get all the effects listed in the node.

Because we aren't actually giving potions but potion effects, the node is renamed from "potions" to "effects". However, to preserve backwards compatibility, both names are supported in this commit.

Closes #453
2018-06-14 00:29:17 +02:00
Andreas Troelsen 84249640d1 Add support for join, leave, and info signs.
The ability to execute commands by hitting signs is already implemented by other plugins, but by creating built-in support for such signs, it's possible to leverage information about the plugin and its current state. This implementation allows for displaying live information about player counts, waves, etc. on the signs in addition to tying actions to them.

Customizable templates defined in the new signs.yml config-file can be bound to signs during the in-game sign creation, and users can define state-specific templates that change based on whether an arena is completely idle, has players in the lobby, or is running and in full swing.

Sign data is stored in data/signs.data as a YAML-formatted file that shouldn't be modified directly, effectively separating configuration (templates in signs.yml) and data (coordinates and parameters in signs.data).

Closes #385
2018-06-14 00:29:11 +02:00
Andreas Troelsen 42416cab2f Allow for dismounting and remounting.
This commit makes it possible for mounted players to dismount. Upon dismounting, the horse AI is set to false to prevent it from moving around. Players attempting to mount an available horse will be thrown off unless they actually own the horse. The owners are free to remount when they want.
2018-05-27 20:08:59 +02:00
Andreas Troelsen c325317153 Add bStats metrics.
Metrics will greatly help the development process in terms of finding out which server versions people are running, as well as which features they are using. For now, we check to see how widespread Vault is, and how many arenas and classes people have.

Advanced bar charts are, at the time of this commit, not supported in the bStats dashboard. When they are supported again, we can look into usage statistics for specific settings and features.
2018-05-14 21:42:33 +02:00
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 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
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
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
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
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 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
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 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
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 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
Andreas Troelsen 2fdfd64ddf Use == operator for comparing EquipmentSlot values. Fixes #361
Because the == operator is null safe, we don't need to worry about null checking.
2017-03-11 13:59:37 +01:00
Andreas Troelsen f212c657b0 Move Messenger announce() methods into Arena.
Since the announce() methods always required an Arena argument, and since the Messenger instance used was always acquired from an Arena instance, there really was no reason for the methods to exist on Messenger.
2017-03-10 23:40:56 +01:00
Andreas Troelsen 56dc504bec Refactor Messenger to allow for custom prefixes.
- Messenger no longer has a static nature and must be instantiated to be used. The prefix is provided in the constructor.
- MobArena instantiates a global Messenger in onEnable() with a prefix string from global-settings. This instance is used by anything that isn't arena-specific, as well as for arenas with no prefix.
- ArenaImpl instantiates a local Messenger in its constructor if, and only if, its arena-specific prefix setting is non-empty. Otherwise it uses the plugin's global instance.
2017-03-10 23:32:52 +01:00
Andreas Troelsen 5d6a7768e8 Refactor logging out of Messenger.
This removes the logging capabilities from Messenger and replaces all references to them with proper logging via Bukkit's PluginLogger that all plugins have.
2017-03-10 21:48:00 +01:00
Andreas Troelsen 9b1866e6cc Replace spaces in class names when toLowerCase'ing them. 2017-02-18 03:36:35 +01:00
Andreas Troelsen fbe80d7ee6 Use config-file names for classes in messages. 2017-02-18 03:34:28 +01:00
Andreas Troelsen 692d7f52dc Add support for a per-arena default class. 2017-02-18 03:27:50 +01:00
Andreas Troelsen d2fd8b4fc2 Add support for bringing your own items into the arena.
This implementation uses a sublcass of ArenaClass to make an implicit My Items class, which restores the player's inventory when granting items.
2017-02-18 03:27:10 +01:00
Andreas Troelsen 51f907218e Use a hardcoded potion map to deal with potion metas. Fixes #312 #343
Thanks slipcor!
2017-02-18 02:43:12 +01:00
Andreas Troelsen 48a85a7e85 Use a copy of the block list in BlockExplodeEvent for the fake EntityExplodeEvent. Fixes #356
The blockList() call returns the actual List<Block> object in the explode event, which means it'll be shared between the the fake event and the original event. As a result, the call to blockList().clear() will clear the shared list, and the following call to blockList().addAll(fake.blockList()) results in trying to add the empty list to itself.

This commit makes sure to copy the original event's block list before sending it to the fake event.
2017-02-14 17:26:20 +01:00
Andreas Troelsen c66321ec78 Remove over-dramatic warning about harmless state inconsistency in start timers. Fixes #317
Okay, "Fixes" would be lying, and that's terrible, but here's something to help you shrug it off: The timer module is a bit of a mess, and since there isn't actually anything "dangerous" about this, let's just calm our tits and focus on other stuff.
2017-02-10 21:47:41 +01:00
Andreas Troelsen f40e54f8bb Minor refactoring of class chests handling. Fixes #318 2017-02-10 21:40:02 +01:00
Andreas Troelsen acbeb3d77f Guard against null scores for players who manage to die in the lobby. Fixes #319 2017-02-10 21:32:56 +01:00
Andreas Troelsen 7e049cdae6 Ignore off-hand interactions for class signs and ready blocks. Fixes #340 2017-02-10 15:52:44 +01:00
Andreas Troelsen b7472dbc94 Prevent mobs from picking up dropped items and blocks. Fixes #344 2017-02-10 15:45:12 +01:00
Andreas Troelsen 788cfefa00 Give all mounts saddles - not just the normal horses. 2016-12-30 01:32:16 +01:00
Andreas Troelsen fb1a87f71b Make sure all mounts are invincible, not just normal horses. 2016-12-30 01:11:56 +01:00
Andreas Troelsen b40b73ea25 Remove support for llamas as mounts (they can't be controlled so no point yet). 2016-12-30 00:34:56 +01:00
Andreas Troelsen 41f0a892c4 Refactor mount spawning due to API changes; fixes an exception thrown when trying to use barding on non-normal horses.
This commit adds support for llamas and removes barding and saddles from non-horse mounts.
2016-12-29 21:56:29 +01:00
garbagemule df43712964 Remove Shulker bullets on session cleanup. 2016-12-29 17:56:43 +01:00
garbagemule 8705b5c9f7 Add support for off-hand items. 2016-12-29 17:56:32 +01:00
garbagemule 558681a2f2 Remove redundant setContents() calls from class chest handlers.
Before, these redundant calls didn't really do anything. Now they mess everything up, because setContents() doesn't set inventory contents only, but the entire inventory instead, because that's so super useful. Well done, boys!

#notsalty
2016-12-29 17:55:46 +01:00
garbagemule 93ce8b9667 Fix Spigot's semi-breaking inventory change.
Because it is clearly impossible to change JavaDocs to correctly describe what a method does, the method setContents() has now been changed to a useless, over-aggressive, inventory-wiping piece of junk that must be invoked before anything else. This commit ensures that armor contents are set after the setContents() method is called, overwriting the nulls that the setContents() method creates.
2016-12-29 17:55:30 +01:00
Andreas Troelsen 11fb0ed573 Give strays a bow just like their normal skeleton friends. 2016-12-17 01:58:46 +01:00
garbagemule 60a173d447 Merge pull request #327 from slipcor/offhand-2
Ignore off-hand interact events in Setup Mode (since Minecraft/Spigot 1.9). Fixes #299
2016-12-17 01:44:43 +01:00
garbagemule 65f33ae1a4 Merge pull request #328 from slipcor/empty-inventory
Always check for both null stacks and "air stacks" (ItemStack ID 0) when checking for empty inventories. Fixes #302
2016-12-17 01:43:46 +01:00
garbagemule bc7c321d28 Merge pull request #329 from slipcor/pets-2
Make pets (ocelots included) sit before teleporting players to the lobby. Fixes #247
2016-12-17 01:41:55 +01:00
slipcor 333a23ecdd fix skeletons only punching with the bow they already have by giving them a new one 2016-12-16 20:36:57 +01:00
slipcor f81921efcd address github issue #247 (sit pets before teleporting) and include cats/ocelots as pets 2016-12-15 22:32:55 +01:00
slipcor cbac56e199 address github issue #302 (joining with empty inventory) 2016-12-15 20:08:00 +01:00
slipcor e6e4782de8 address github issue #299 (ignore offhand interact events thrown since Spigot 1.9) 2016-12-15 18:49:30 +01:00
slipcor 3b88b889d6 update to Spigot 1.11, fix entity spawning errors, remove redundant definitions 2016-12-15 13:13:21 +01:00
garbagemule dbff678660 Add support for killer bunnies. 2015-09-16 18:51:43 +02:00
garbagemule 4d2b6927d4 Add support for elder guardians. 2015-08-23 15:34:22 +02:00
garbagemule 3a20be3db9 Make root-target find the nearest ground block to root to. 2015-07-28 20:25:08 +02:00
garbagemule 39196c7b61 Unwrap potential Player proxies in commands. 2015-07-17 17:50:51 +02:00
garbagemule 79ca18aa41 Fix default boss health value. 2015-07-17 16:41:58 +02:00
garbagemule d32cd22a98 Make monster types case-insensitive. 2015-07-17 16:12:23 +02:00
garbagemule a9eab13842 Fix Spigot block explosion issue. 2015-07-17 16:11:00 +02:00
garbagemule 95aebcf333 Merge branch 'ma-creature' 2015-07-17 04:45:57 +02:00
garbagemule d3c5535f61 Cast null instead of creating a new set. 2015-07-17 04:45:48 +02:00
garbagemule eda6e6e1f3 Static map initializer before constants. 2015-07-17 04:44:59 +02:00
garbagemule 0e814b9c0f Convert MACreature to class. 2015-07-17 04:25:24 +02:00
garbagemule aafeb93d38 Update for Spigot and mavenize. 2015-07-17 03:38:41 +02:00
garbagemule e663a10a2a Fix Spigot issue with skeleton/wolf targetting. 2014-12-13 20:29:02 +01:00
garbagemule 2e397fd123 Really fix the Spigot health issue (with a twist). 2014-12-13 20:28:14 +01:00
garbagemule a8755ea496 Add a guard for ridiculous Spigot health issue. 2014-12-08 19:37:11 +01:00
garbagemule 246c05e7a9 Initial work on fix for water not removing properly. NOT ACTIVATED. 2014-12-08 19:23:21 +01:00
garbagemule bca1d387a4 Allow for spaces between comma-separated potion effects. 2014-12-08 16:48:53 +01:00
garbagemule 243c5ea6ea Make numeric regexes require at least one number to match. 2014-12-08 16:45:05 +01:00
garbagemule 55e0500bae Allow for lower case potion effect names. 2014-12-08 16:43:15 +01:00
garbagemule 409c3f6c14 Swap amplifier and duration parameters in effect parser.
This changes the format from:

  <effect>:<duration>:<amplifier>

to a (pressumably) more user-friendly format of:

  <effect>:<amplifier>:<duration>

The reason for this swap is that the duration is more likely to be
wanted left at default than the amplifier. From previous user input
on the matter, it sounds like users generally want the bosses to have
"permanent" or "infinite duration" effects, and this change makes it
a little easier on them, not having to specify a duration.
2014-12-08 16:38:33 +01:00
graywolf336 47f22f75ab If no duration provided, potion effects on bosses will last forever. 2014-11-27 22:05:38 -06:00
graywolf336 1090550a3b Add potion effects to bosses when they spawn.
With this feature you can add potions to the bosses when they spawn,
adding the ability to add strength to the boss for the first 30 seconds
making it harder for the first few seconds and once the effect wears
goes away the boss becomes easier. The syntax is in the same style as
potion items, except it uses either the potion effect enum name or the
potion effect id.

POTION_EFFECT:duration in seconds:amplifer

SLOW:360:4;INVISIBILITY:36000:0

If no duration is given, the plugin will default to sixty seconds. If
the amplifer was not provided, the plugin will default to zero. The
potion effect amplifcation starts at 0 being level 1.
2014-11-27 03:37:14 -06:00
garbagemule 0649d1ba1f Version 0.96.7 2014-08-02 07:34:04 +02:00
garbagemule ea2cb4baf2 Fix auto-ignite-tnt not working with protect: false 2014-08-02 07:01:56 +02:00