Commit Graph

71 Commits

Author SHA1 Message Date
Andreas Troelsen
4f11889549 Add per-arena setting announcer-type.
Introduces the concept of an Announcer, which is invoked whenever the
`announce` methods on the Arena interface are invoked. Previously, all
announcements would simply be sent to the arena's Messenger, but this
new feature allows us to move them up into titles to help declutter the
somewhat overloaded chat box.

By default, to help people discover the new feature, the announcer type
is `title`, but it is possible to switch back to `chat` for the original
behavior.

Closes #272
2020-08-22 11:32:45 +02:00
Andreas Troelsen
64d55673a4 Add per-arena setting arena-warp-offset.
This commit introduces a quality-of-life feature for spreading players
out during the warp to the arena floor. The feature is configured via
the new per-arena setting `arena-warp-offset`. When the value is greater
than 0.01, MobArena will add a random number of units between 0 and the
offset value to the X and Z axes in either direction. For example, if
the value is set to 3, players will be teleported to a random location
in a 3x3 square centered on the arena warp, rather than directly to the
arena warp itself.

Closes #371
2020-08-20 23:30:57 +02:00
Andreas Troelsen
b343976dc8 Clone class chest contents before modifying them.
Certain class chest items are cloned before they are made unbreakable,
but not all. This commit changes that, so all items in the input array
are cloned prior to setting the unbreakable flag on them. The items that
were previously cloned specifically no longer need to be, since they are
included in the initial cloning.

Fixes #637
2020-08-19 23:03:08 +02:00
Andreas Troelsen
7f7fb1631c Bump to HIGHEST priority for PlayerRespawnEvent.
Plugins like Multiverse and EssentialsX have features that override the
world spawn location for players respawning both with and without bed
locations. If MobArena catches the PlayerRespawnEvent too early, these
plugins will likely overwrite the respawn location set for players that
respawn after dying in an arena session.

Because MobArena is a minigame and its respawn manipulation logic only
runs for respawning arena players, it is perfectly reasonable for it to
get the final say in where these players should respawn. It would have
been nice to just use `HIGH`, but that is what EssentialsX runs at, so
we gotta go higher than that.
2020-08-19 22:55:23 +02:00
Andreas Troelsen
84a7a2ed8a Don't kick players when spectate-on-death: true.
This commit forgoes some of the work done in the join/leave refactoring
of commit b1c6b61827.

The intent behind the original commit was to make the join/leave process
a very strictly defined set of steps that would work atomically to try
to ensure a stable, predictable process. As a result, the idea of making
spectators out of respawning players meant first kicking them out of the
arena and then re-joining as spectators, as if they had manually typed
`/ma leave` followed by `/ma spec`.

However, on some multi-world setups, this process causes people to get
thrown around a bit, which makes for a poor user experience. This commit
changes the behavior when `spectate-on-death: true` such that the player
isn't kicked, but is instead added to the spectator player pool when
they respawn. If the flag is false, players will still get sent to the
spectator area for one tick and then immediately kicked out as if they
had manually typed `/ma leave`. This does create a little bit of jumping
around, but because there is only one world change (as there would be
anyway), it is deemed acceptable at this point in time.

Closes #508
2020-08-19 22:51:27 +02:00
Andreas Troelsen
7fc0473a72 Guess Equippables from Material name suffix.
This commit changes the way Equippable wrappers are created, such that
they more closely match the way class chest armor pieces are "guessed".
That is, instead of looking directly at the Material value of the given
item, we instead look at the name _suffix_, i.e. the part after the last
underscore in the name, e.g. `BOOTS` in `IRON_BOOTS`.

The neat thing about this approach is that it is compatible with future
items that follow the same naming convention, such as Netherite armor
pieces.

The downside is that it is stringly typed and not particularly "pretty",
and if the naming convention breaks or new items are introduced (such as
the elytra), we will have to make modifications anyway.

Fixes #636
2020-08-09 12:42:44 +02:00
Andreas Troelsen
b0969c655c Prevent guardians from instantly retargeting.
The vanilla behavior for most mobs is that they just stop minding their
targets' business if aggro is lost. The same applies to guardians and
elder guardians.

To prevent the pace of gameplay from stagnating, MobArena compensates
for target loss by helping the mobs find a new target. The issue with
this in terms of guardians is that breaking line of sight is the only
way - besides killing it very quickly - to avoid taking damage from a
guardian due to its lock-on laser attack. This means that guardians and
elder guardians need to be excluded from the retargeting logic to make
sense in an arena setting.

This commit introduces a new EnumSet of EntityTypes to exclude from the
retargeting logic. It is not a particularly pretty solution, especially
not since ArenaListener is such a huge class already, but it does make
it easier to add more mobs later down the road, and it does a slightly
better job at giving way to a config setting at some point.

For the Mobs Rework, a per-monster flag like `auto-retarget` or similar
might be a much better solution, so it's possible to have encounters
like a small batch of guardians that _don't_ lose their targets but have
very little health, so the "race against time"-aspect can exist, but in
a much more configurable way.

Fixes #601
2020-07-28 09:45:18 +02:00
Andreas Troelsen
6de0a2fa83 Fix soft-restore for blocks broken by players.
This commit fixes the per-arena config setting `soft-restore`. Due to
commit 92c4ce1a8b, the soft restore logic
won't run on BlockBreakEvents, because to reach that specific part of
the event handler, the `protect` flag has to be set to `true`. However,
due to an early return in the soft restore logic if the `protect` flag
_is_ set to `true`, it is effectively impossible for it to run.

The fact that this functionality has been broken for over 6 years (!)
with almost no reports of it is perhaps a testament to how little it is
being used in the wild.
2020-07-21 16:32:59 +02:00
Andreas Troelsen
c682e45714 Remove MagicSpells integration.
The integration only works reliably with the `clear-wave-` settings set
to `true`, because it relies on there being only one "current" wave.
This is a fundamental issue with the way sessions run right now, and is
another good example of why the Sessions Rework is necessary.

It is possible to achieve the exact same functionality by just making a
couple of Upgrade Waves before and after the waves that need to have
limited skill sets (thanks Lucy). With just a couple of quality-of-life
features like wave "triggers", it's possible to make things just the way
they were with the integration, but by using some more general building
blocks.

Closes #609
2020-07-21 09:14:58 +02:00
Andreas Troelsen
962eb7aaba Improve config-file errors from /ma setting.
Catches ConfigError and prints its message rather than letting it bubble
up to the command handler as an uncaught exception. This means that
instead of seeing "An internal error occurred...", command senders now
see the underlying error message, as well as a short message telling
them to fix the error in the config-file and reload.

Closes #599
2020-05-31 21:12:47 +02:00
Andreas Troelsen
62496127d7 Use toUpperCase() in SetPlayerTime step.
This commit fixes the `player-time-in-arena` per-arena setting by switching to `toUpperCase()` on the string value, which means that the values can actually result in something meaningful, rather than always throwing an exception.

The feature was broken in commit b1c6b61827, and it appears to be the only such instance to sneak through.

Fixes #621

Co-authored-by: Bobcat00 <Bobcat00@users.noreply.github.com>
Co-authored-by: Chew <chew@chew.pw>
2020-05-17 08:22:56 +02:00
Nesseley
7e37d93a0e Rework Root Target.
This commit completely reworks the Root Target ability implementation by
replacing the repeated teleportation code with potion effects.

The old implementation relied on teleporting the target every tick for a
given duration, but because teleporting also involves pitch and yaw, the
result was a constant "snapping back in place" experience.

The new implementation works by applying the following potion effects
with a very large amplification:

- Slowness, to prevent the player from moving out of place.
- Slow falling, to negate fall damage.
- Negative jump boost, to prevent the player from jumping around.

Note that the jump boost uses a _negative_ amplification to make it have
the inverse effect, i.e. a much worse jump ability. It is still possible
to jump an arguably negligible amount away from the root location.

Fixes #490
2020-05-04 07:57:43 +02:00
Nesseley
e8cce8e620 Add support for color codes in boss names.
Translates color codes for the boss name string right before setting it
in the BossWave object.

Closes #610
2020-04-27 11:21:05 +02:00
Nesseley
5e7485682a Add support for Elytra as chest pieces in class chests.
Makes the class chest armor guessing logic pair `"ELYTRA"` up with the
chest piece slot. This specific matching works, because there are no
underscores in the `"ELYTRA"` item name.

Fixes #616
2020-04-25 21:20:07 +02:00
Chew
c9b36f4993 Allow non-existent pet-items nodes.
If someone spins up MobArena with a really old config-file or simply
removes the `pet-items` section, the plugin throws an NPE. This commit
fixes that by allowing the section to not exist.

It might be a good idea to log some helpful information, but let's wait
and see if this isn't good enough.

Fixes #606, closes #608.

Thanks Chew!
2020-03-29 05:32:08 +02:00
Andreas Troelsen
86be8bdfbd Add changelog entry for 90d1f211fa.
Adds a changelog entry for the changes made in 90d1f211fa.
2020-01-13 11:07:33 +01:00
Andreas Troelsen
5f7be69f0f Add changelog entry for 6e8a3e1626.
Adds a changelog entry for the changes made in 6e8a3e1626.
2020-01-11 01:37:08 +01:00
Andreas Troelsen
5c30164ba7 Release 0.104.2. 2020-01-03 21:28:44 +01:00
Andreas Troelsen
14ad15b15d Cross check arena/lobby regions in intersects().
This commit changes how the ArenaRegion `intersects()` method works:

- The implicit null checks in the `setup` and `lobbySetup` flags have been replaced with actual null checks inside the auxiliary `intersects()` function. Not only does this make the auxiliary method more robust for potential future use, it also helps tidy up the code a bit. So neat!
- The semantics have changed, since `setup` depends on more than just the `p1` and `p2` points. This fixes an (unreported) bug where the check would report a false negative in case an overlapping arena region was defined, but e.g. the arena warp was missing.
- Instead of only checking arena vs. arena and lobby vs. lobby, we now also check arena vs. lobby and lobby vs. arena. That is, if the arena region is defined, we check it against both the arena region and lobby region of the other ArenaRegion (if they are defined). Same deal with the lobby region. This should ensure that no combination of overlaps pass through the check.
2020-01-03 02:05:24 +01:00
Andreas Troelsen
3a017b179d Fix NPE in region overlap check.
This commit fixes an issue with the new `intersects()` method on ArenaRegion. Instead of blindly assuming that the region points `p1` and `p2` are set when the method is called, we first make sure both regions are properly set.

Fixes #590
2020-01-03 01:28:33 +01:00
Andreas Troelsen
62dd39c28a Release 0.104.1. 2019-12-31 23:27:49 +01:00
Andreas Troelsen
77ead3de5c Report overlapping arena regions on load.
This commit introduces an `intersects()` method on ArenaRegion that
allows us to check whether two regions intersect.

The new method is employed in ArenaMasterImpl during arena load. If an
arena's region intersects with any other arena's region (in the same
world), we print a warning to the server log.

Fixes #367
2019-12-31 23:24:30 +01:00
Andreas Troelsen
eed5117454 Fail fast if world is null when parsing locations.
This commit introduces a null check in the ConfigUtils `parseLocation`
method. If the world of a location string does not exist, the method now
throws an IllegalArgumentException, which allows callers to fail more
gracefully instead of having to resort to null checks.

Additionally, the parsing of exit warps, leaderboards, or linked class
chests is wrapped in try-catch statements that re-throw ConfigErrors
for better error reporting.

Fixes #421
2019-12-31 20:40:51 +01:00
Andreas Troelsen
01c56fdd6a Rewrite plugin version checker.
This commit removes the old version checker that used the DBO resource
page and replaces it with a custom checker that uses the "legacy" Spigot
resource API. The Spigot API is much more lightweight and doesn't
require any sort of parsing.

The new version checker uses a simple cache, keeping version checks
fresh for up to one hour, reducing the need to go fishing on every op
login. The cache resets on restarts, though, but this is acceptable.

Note that no attempt has been made to ensure correctness on multiple,
consecutive invocations when the cache is stale. If a cache refresh is
initiated, all update checks invoked before the cache refresh has ended
will behave as if no update is available. This is acceptable, because
update checks are non-essential, the time frame is extremely narrow, and
the most common result of an update check is "no updates available",
since the amount of update checks made is vastly greater than the amount
of updates released.
2019-12-31 16:10:43 +01:00
Andreas Troelsen
ab2fefd3d3 Use regular player name when tab completing /ma kick and /ma restore.
Since the actual execution of these commands use the regular player name
instead of the display name, the tab completion is useless if it doesn't
also use the regular player name.

Fixes #589
2019-12-29 17:52:34 +01:00
Andreas Troelsen
9890c13391 Rewrite EntityTargetEvent handling.
This commit is a complete rewrite of the target event handling logic in
the ArenaListener class.

Instead of the complex, inconsistent code structure with too many line
breaks between control flow branches, we just have a thin logic wrapper
that delegates the event handling to smaller, more focused functions
that handle arena pets, arena monsters, and foreign entities on their
own.

A couple of auxiliary methods are introduced to try to limit the amount
of warnings produced by checking set membership with `contains()` when
the entity/target is an Entity and the collection is a sub type.

Fixes #572
2019-12-29 17:34:56 +01:00
Andreas Troelsen
a59a4f911d Don't check for recurrent waves on join.
This commit removes a condition in ArenaImpl#canJoin(Player) that checks to see if the arena's WaveManager has any recurrent waves.

Removing this condition is safe, because the WaveManager already makes sure to have a "catch all" default wave at hand for when no wave definitions match a given wave number. As such, the condition in ArenaImpl is completely unnecessary, and was in fact the root cause of a bug.

Fixes #566
2019-08-16 00:46:01 +02:00
Andreas Troelsen
57ce1e3970 Release 0.104. 2019-08-09 00:04:06 +02:00
Andreas Troelsen
fb13eac16f Call pet spawning logic in Upgrade Waves.
Due to the package structure and location of MASpawnThread, SpawnsPets doesn't need to be opened up for this to work.

This change opens up for quite a few different upgrade strategies, since pet items obtained outside of Upgrade Waves are transformed as well. It is technically a breaking change, because it breaks the invariant that "after arena start, no items are transformed to pets". However, since pet items are customizable, it is possible to just change the `bone` to `sponge` in the config-file if bones carry some sort of implicit meaning in an existing setup.

Closes #524
2019-08-08 00:23:51 +02:00
Andreas Troelsen
e3a4b3b2a0 Add support for potion effect upgrades in Upgrade Waves.
It doesn't seem like there was any real reason to leave out potion effects as upgrades in Upgrade Waves previously, so they were likely just forgotten in the Things API overhaul.

Closes #565
2019-08-07 23:43:11 +02:00
Andreas Troelsen
127d273fd6 Keep track of Vexes summoned by Evokers.
This is a bit of an overhaul of how CreatureSpawnEvent is handled:

- Events happening outside the arena region are still ignored, as are armor stands placed in edit mode.
- Otherwise, if the arena isn't running, we blanket reject all entities.
- Player-mode iron golems and snowmen are still allowed.
- Anything that isn't spawned by a plugin is rejected, _unless_ it is a Vex spawned with "default" spawn reason, which is what the Evoker summon spell uses.

In the end we have a "custom" spawn reason inside the arena region while it's running, which is perfectly "legal". And because of the unfortunate use of Creature (instead of Mob) in MACreature, Slimes and Magma Cubes still need to be handled separately here.

Fixes #564
2019-08-07 23:41:02 +02:00
Andreas Troelsen
b44b808d38 Make class pets aggro hostile mobs who attack their owners.
When a player takes damage from a hostile mob, the player's class pets will have their target set to that mob. This means that even zombies can function as "real" pets!
2019-08-05 16:16:18 +02:00
Andreas Troelsen
cb8983b162 Drop support for auto-respawn.
This commit removes the `auto-respawn` arena setting and the logic associated with it.

MobArena's hacky implementation of auto-respawning is buggy and discouraged. To get true auto-respawn functionality we'd have to move to the Spigot API instead of the Bukkit API.
2019-08-05 16:00:01 +02:00
Andreas Troelsen
bbd70d0692 Add names to class pets.
This commit adds custom names to class pets in the form `<player name>'s pet`. This should help players more easily distinguish between pets and hostile mobs.
2019-08-05 14:34:19 +02:00
Andreas Troelsen
c6a695e2c3 Rework class pet parsing and handling.
This commit changes the pet parsing and handling such that it is a lot more dynamic. Rather than limiting pets to wolves and ocelots, any living entity is now a potential pet. This means that we can do away with the logic that specifically targets the Wolf and Ocelot interfaces and instead work with the more general Tameable interface. As a result, the discrepancies between Minecraft 1.13 and 1.14 in this regard are largely irrelevant, because server owners can just specify which entity they want to spawn given which item in their config-files.

MonsterManager's two Wolf- and Ocelot-specific addPet() methods are replaced with a generic addPet() method that takes an owner (Player) and a pet (Entity). This is technically a breaking API change, but MonsterManager is an internal component that is very unlikely to be used outside of MobArena.

The `global-settings` node in the config-file can no longer be forced into strict compliance via ConfigUtils, because the `pet-items` node is now dynamic rather than static.

The default `pet-items` node in the config-file no longer has `ocelot` in there to avoid confusion on 1.14. It now only contains `wolf` and people will have to add their own ocelot/cat in if they haven't added it already.

Fixes #563
2019-08-05 14:32:23 +02:00
Andreas Troelsen
3c533ea683 Explicitly make pig zombies angry when they spawn.
This commit changes the MACreature spawn logic such that any pig zombie spawned will be angered immediately.

Fixes #561
2019-08-03 20:33:16 +02:00
Andreas Troelsen
7f1c4b1b87 Don't assume implemented interfaces by EntityType in SitPets.
This commit changes how SitPets determines if a nearby entity is "pet material". Instead of assuming that wolves and ocelots are tameable, we check for the Tameable interface. This means that we get rid of the "concrete" types, Wolf and Ocelot, and also fixes a bug on Minecraft 1.14 servers where ocelots are no longer tameable, but cats are. It also kinda catches parrots, but they will not sit if they are flying or perching on the player's shoulder when joining.

Because ocelots are no longer tameable in 1.14, they shouldn't cause trouble here, but because they are tameable in 1.13, we need to rely on the Tameable interface to maintain both backwards and forwards compatibility.

Fixes #548 (kind of - no more exceptions thrown, but the pet ocelots from SuperLuckyBlock may misbehave, however that is a different issue).
2019-07-26 23:13:34 +02:00
Andreas Troelsen
81dfb71fe1 Add basic tab completion support.
This commit adds support for basic tab completion for most of the commands that take arguments. Some completions are somewhat intelligent, e.g. `/ma join` which only lists enabled and "functional" arenas that the given player is permitted to use. Others are just kinda dumb, e.g. `/ma enable` which indiscriminately lists all arenas.

Closes #405
2019-07-26 22:26:10 +02:00
Andreas Troelsen
d5676b7b74 Fix check for arena monsters in monster damage logic.
This commit changes how the final "catch all" works for incoming monster damage. Instead of checking if the damager entity is a LivingEntity, we check if it is a monster of the arena and then proceed as normal.

Note that this change may make it possible for monsters in the arena to take damage from non-arena entities. The so-called "catch all" doesn't really catch everything, but it does catch the infighting that it was designed to catch.

One "not thought of" damage source is that of player-made golems, so coincidentally, this commit fixes #550.
2019-07-25 23:15:05 +02:00
Andreas Troelsen
054220a32e Add support for extended and/or upgraded potions in the item syntax.
This commit adds support for altering the data portion of a potion item by prefixing either `long_` or `strong_` to get extended duration or level II versions of the given potion, respectively.

Closes #520
2019-07-24 20:15:13 +02:00
Andreas Troelsen
fa2016acb5 Drop support for getting potion effect types by magic number IDs.
getById() is deprecated, and while this does break existing functionality, it is a good kind of breakage because it forces people over to the name-based IDs, which they will eventually be happier with.

Partial fix for #406
2019-07-22 01:03:17 +02:00
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
d287a35137 Release 0.103.2. 2019-04-23 11:21:44 +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