Commit Graph

22 Commits

Author SHA1 Message Date
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
2f64783649 Release 0.103.1. 2018-12-31 15:33:06 +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
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
Andreas Troelsen
fe5571c75b Update changelog with change from 6a8c6a9. 2018-09-23 15:41:37 +02:00
Andreas Troelsen
7962842be1 Release 0.103. 2018-08-28 22:00:59 +02:00
Andreas Troelsen
d17b588647 Update Thanks in changelog.
Thanks, kitty!
2018-08-24 19:44:23 +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
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
Andreas Troelsen
95e2abdee9 Update changelog with /ma ready command. 2018-08-19 11:05:00 +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
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
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
c1375a31f5 Add changelog.
This, along with a (currently not committed) script to generate github releases and Spigot/DBO formatted release notes from this changelog, should reduce some of the friction associated with new releases.
2018-08-05 20:47:06 +02:00