Commit Graph

1052 Commits

Author SHA1 Message Date
Andreas Troelsen d4dcc8dc90 Don't nag players with `mobarena.admin.teleport`.
Changes the behavior of the ArenaListener's teleport event handler such
that it _ignores_ teleport attempts instead of _rejecting_ them when the
player in question has the `mobarena.admin.teleport` permission. Because
the global listener's event handler only ever checks the permission if
at least one per-arena listener has _rejected_ the teleport attempt, and
none of them have explicitly _allowed_ it, the change means that it will
never check the permission, because its internal `allow` flag will never
change to `false`. Thus, the check can be safely removed from the global
listener's logic.

When the response is to ignore instead of reject, the message that would
have otherwise been sent to the player is skipped. This fixes #702.

It is perhaps tempting to move the permission check up into the section
of sanity checks in the global listener, but this is very specifically
avoided to allow MobArena to _uncancel_ teleport events that have been
cancelled by other plugins, but that MobArena might need to go through.
Please see afcc526a71 for more info.
2022-02-12 19:06:40 +01:00
Andreas Troelsen 77b2525707 Cancel damage to players by pets.
This is technically not necessary when pets are simple entities like
wolves and zombies, because these types of pets will never target and
thus attack other players in the arena. However, projectile entities
such as Blazes and Ghasts may hit players in the line of fire, and so
any such damage should be cancelled.

Fixes #712
2022-02-12 17:55:58 +01:00
Ghmmy d5ea15fa08
Add per-arena setting `clear-wave-leeway`.
Introduces a new arena setting that changes the "emptiness check" for 
`clear-wave-before-next`, `clear-wave-before-boss`, and the final wave 
check, allowing for a customizable _leeway_.

By default, the leeway is 0, which means the monster set has to be
completely empty for the checks to pass. With a value of 2, the set
may contain up to two monsters for the checks to pass, and so on.

The leeway should help alleviate some of the issues some people have
with their arena sessions when monsters "disappear" behind terrain or
end up in hard-to-reach areas. This is by no means a real "solution"
to the underlying problem, since the build-up of monsters in longer
sessions will just result in the issue being pushed to later waves.

We'll see if the setting leaves any additional customization to be
desired and perhaps defer any such requests to the Sessions Rework.

Closes #706
2022-02-12 16:57:47 +01:00
sepulzera be6be4bb98 Reset player velocity on select teleports.
Sets the player fall-distance to 0 before performing a player teleport
during "move player" steps. This should cancel out the any fall damage
that may have built up before the teleport was initiated.

Fixes #698

Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
2022-02-12 16:24:44 +01:00
Andreas Troelsen 9164b125bd Allow flaming arrows to ignite TNT.
It turns out that, according to the Spigot API, flaming arrows actually
_change_ TNT blocks to air before/instead of igniting them. While this
is a little counter-intuitive, the fix seems to revolve around allowing
the change to happen if the changed block is TNT and the "changer" is an
arrow.

Allowing the change event to happen means "foreign" primed TNT entities
will spawn, which makes it necessary to clean them up during the session
cleanup phase in ArenaImpl.

Fixes #696
2021-12-05 17:30:24 +01:00
Andreas Troelsen c80f0375ee Copy cancel state to fake EntityExplodeEvent.
It's not clear if this change actually solves the underlying issue,
because it has not been tested in a controlled environment. However,
considering the EntityExplodeEvent constructor, which doesn't take a
cancel state value, and the `HIGHEST` priority setting of MobArena's
event handler, the issue is realistic, and this change very likely
solves the issue.

Fixes #704
2021-12-05 16:18:54 +01:00
Andreas Troelsen 2c12112fd0 Update JUnit to 4.13.2. 2021-10-13 23:25:13 +02:00
Andreas Troelsen fe9d160edd Update Mockito to 3.12.4. 2021-10-13 23:25:13 +02:00
Andreas Troelsen 4348a0497e Use arena slugs in arena sign update handler.
The arena signs predate the use of arena slugs everywhere, so something
slipped through the cracks in this regard. Incidentally, the handler for
arena updates is one of the few classes in the signs package that has no
unit tests, probably due to it being "obvious implementation". Not so
obvious after all, it seems, so now we have a basic test for it.

Fixes #705
2021-10-13 23:25:13 +02:00
Maroon28 3693c039a6
Force adult entities; additional baby entities.
This commit (unfortunately) makes two somewhat unrelated changes:

- Forces certain ageable entities into adulthood to prevent the occasional baby spawns (fixes #687).
- Introduces support for baby versions of certain ageable entities (fixes #689).


Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
2021-10-13 23:24:56 +02:00
Griffin caee8be6ca
Add boss abilities with `all` modifiers.
Introduces four "new" boss abilities that work like their pre-existing counterparts, but affect all players in the arena. This makes the four _ability sets_ a bit more complete, as it were, in that it is now possible to choose between single targets, nearby, distant, or _all_ players for the given abilities.

Closes #434
2021-08-30 19:02:30 +02:00
Nesseley c9766dee97 Use spaces for "empty" titles.
Due to a breaking change in Spigot 1.17, sending a title with an empty string no longer works, even if a non-empty subtitle is provided. The TitleAnnouncer and TitleHealthBar components only use the subtitle portion of the title API to avoid obtrusive behavior.

With this commit, the two components send a single space character as the title. Effectively, there is no difference between showing the empty string or a single space on the client-side. It's a dirty hack to fix something that should be fixed in Spigot instead, but odds are that it won't be.

Fixes #683
2021-08-09 21:32:55 +02:00
Andreas Troelsen c143cc81c9 Add per-arena setting `auto-leave-on-end`.
Introduces a new arena setting to force spectators to leave the arena
when the current session ends. If set to `true`, it "overrides" the
behavior of `spectate-on-death: true` when players respawn, such that
they only become spectators if there is an active arena session.

The respawn behavior technically means that it is possible for a player
to begin spectating "the next session" if a new session begins between
them dying and clicking Respawn on the death screen. Ideally, we would
want the player to auto-leave, because the session _they_ participated
in ended, but we don't have a concept of "previous sessions", so this
quirky behavior will have to do.

Closes #682
2021-08-08 00:56:41 +02:00
Andreas Troelsen 52226fa1c9 Make Thing extend ThingPicker.
By turning things into their own thing pickers, we can avoid creating a
bunch of SingleThingPicker wrappers, which are now redundant. Because
the semantics of using things and thing pickers are quite different, it
does perhaps make it necessary to be a bit more careful about picking
the right type.
2021-08-07 16:08:23 +02:00
Maroon28 1c225d93f9
Make piglins and hoglins immune to zombification
When piglins, piglin brutes, and hoglins go through zombification, the current entity is removed, and a new one spawns. MobArena prevents the zombified entity from spawning, so it feels like the mobs just "vanish".

We don't actually want the mobs to zombify, however, so this commit makes them immune to the zombification process. Note that this shouldn't cause any problems on server versions prior to 1.16, because the piglin and hoglin keys never get registered on those versions, so there is no risk of hitting those branches in the `switch` statement.

Fixes #684

Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
2021-08-07 16:05:18 +02:00
Bobcat00 6be130daf1
Make pet names per-class configurable.
Adds a new optional `pet-name` property to arena class configurations that lets server owners set a custom pet name template instead of the hardcoded "<player>'s pet". This allows for translation and color coding. To accommodate setups where the player's "display name" isn't a good fit, e.g. because it is too long, the more generic "player name" is available for use instead.

Closes #595 

Co-authored-by: Bobcat00 <Bobcat00@users.noreply.github.com>
Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
2021-08-07 15:13:44 +02:00
Maroon28 a21f47e193 Don't remove monster weapons.
Changes the way monster equipment is handled from clearing _all_ items to clearing just the armor contents. This means that monsters that naturally spawn with weapons won't need their weapons added back in.

It also means that monsters that _occasionally_ spawn naturally with weapons now may do that in arenas. This is deemed acceptable, because:

- occasional weapons don't have as much of an impact as occasional armor,
- the forwards compatibility aspect is too valuable to pass up on, and
- should occasional weapons become too much of an issue, they can be conditionally removed, i.e. we can implement the _inverse_ behavior of what we had previously.

Fixes #641
Fixes #686

Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
2021-08-07 14:59:07 +02:00
Andreas Troelsen 7b9a9505b9 Reformat code in `things` package.
This is mostly just line breaks at the top and bottom of classes and
interfaces, but also marks some fields `final`.
2021-08-07 12:29:44 +02:00
Andreas Troelsen cad2eef8ba Optimize imports in `things` package.
We're good with on-demand imports for the static Hamcrest and Mockito
functions in test code, because the arrange and assert steps of unit
tests all make use of them, so it's known where they come from.
2021-08-07 12:20:45 +02:00
Andreas Troelsen 9fec49cc58 Make ThingGroupPicker aware of result set size.
This commit makes the ThingGroupPicker return different values depending
on the size of the picked result set. If the set is empty, the picker
returns null, emulating a NothingPicker. If the set is a singleton, the
element itself is returned, emulating the SingleThingPicker. Finally, if
the set contains more than one element, a ThingGroup containing those
elements is returned.
2021-08-07 01:36:37 +02:00
Andreas Troelsen 823be96b4e Guard against `nothing` in ThingGroupPicker.
This commit filters the result list of a ThingGroupPicker by a non-null
predicate to avoid null values in the resulting ThingGroup instance.

Since null values represent `nothing`, and we don't usually announce it
when players earn a `nothing` reward, it makes sense that they wouldn't
bubble up and somehow "manifest" in groups of things either.

Fixes #691
2021-08-07 01:36:35 +02:00
Andreas Troelsen 286071871f Add support for angry bees.
This commit introduces a new type variant, `angry-bee`, which is a bee
whose anger level is maximized upon spawning, much in the same vein as
its angry wolf cousin.

Note that bees are not available prior to Minecraft 1.15, so a sentinel
`null` name is used in the registration to prevent warnings from being
logged on server versions that don't have a concept of bees.

Closes #584
2021-07-30 18:21:41 +02:00
Andreas Troelsen c1716709f3 Add changelog bullet about targeting 1.17.
Because this bullet covers both the commit with the version bump and the
following compatibility commits, it didn't really fit properly into any
one of those commits, so now it gets its own!
2021-07-30 18:21:41 +02:00
Andreas Troelsen 15698d3eee Use block data to check if blocks are signs.
Instead of relying on the evolving Material enum values, we can use the
new BlockData API as advised by some of the folks "in the know". It is
unclear how much of a performance impact the the "block data gathering"
and `instanceof` checks incur, but this is a pretty secluded place in
the code base, so probably nothing to worry about.

An alternative solution could have been to check if the _name_ of the
Material equals "SIGN" or "WALL_SIGN", or ends with "_SIGN". That should
cover all cases in a sorta kinda safe manner, but it isn't as resilient
as the BlockData/BlockState hierarchies.

We could also employ the new Materials utility class and enumerate all
sign types by name and just check for membership of the resulting set,
but this creates another brittle crash point.
2021-07-30 18:21:41 +02:00
Andreas Troelsen b4cd509eff Use "legacy-aware" utility class for Material types.
Introduces the Materials utility class, which works much like the static
MACreature registration process, but for certain material types. Instead
of storing everything in a stringly typed map, certain Material values
are stored as constants.

Right now it's just the `OAK_SIGN`/`SIGN` pair for the autogeneration in
MAUtils, and chances are we can throw it out at some point in the near
future, but at least now there's room for more materials, should the
need arise.
2021-07-30 18:21:41 +02:00
Andreas Troelsen b49920fc38 Make fallback default wave consistent with default config.
Changes the fallback default wave in the wave parser to be consistent
with the default wave of the default config-file. Not a huge deal, but
it does feel a bit more neat.
2021-07-30 18:21:41 +02:00
Andreas Troelsen 36237ebe2d Replace pig zombies in the special wave of the default config.
Replaces the `zombie-pigmen` entry in the `spec1` wave of the default
configuration with `slimes-big`. This is due to the pig zombie rework
into piglins, which makes the custom name a little flaky. If we ever
decide to ditch the custom names somehow, this will probably make such a
transition a little easier.

While `slimes-big` is also a custom name, so are `powered-creepers` and
`angry-wolves`, but at least they are "API stable" in comparison, which
is really what this change is about.
2021-07-30 18:21:41 +02:00
Andreas Troelsen 4de0ce258b Tidy up code style in MACreature.
It's K&R style braces in all modern portions of the code base, and
IntelliJ keeps complaining about final values, so let's just make it
happy.

The `plural` field should go away at some point, but for now it's fine
to just null it out, since the legacy `register()` method is only ever
used by the deprecated-for-removal constructors, both of which actually
set it to something non-null.
2021-07-30 18:21:41 +02:00
Andreas Troelsen 72f4d16e6f Deprecate old MACreature constructors for removal.
The new constructor and registration method pair is what other plugins
should be using. They provide a slightly cleaner interface, and we don't
need so many different ways to do the same thing.
2021-07-30 18:21:41 +02:00
Andreas Troelsen 490df61375 Refactor MACreature registrations.
This commit changes the way MACreature initializes its internal map of
available monster types. Specifically, it replaces all static references
to EntityType enum values with a series of registration helper methods
that try to resolve EntityType enum values from a given set of strings,
stopping on the first match. If nothing matches, no registration, but a
warning is logged unless a specific sentinel `null` value is passed as
an argument, in which case the key is just silently skipped (not in use
as of this commit, but it will be necessary for modern types like bees
from 1.15+).

While this is arguably a huge step back in terms of type safety, it does
make the code base more resilient to API version bumps, and it allows
compiling against modern API versions and still run on older (1.13-1.16)
servers. It _does_ mean that changes to the EntityType enum (such as
PIG_ZOMBIE to ZOMBIFIED_PIGLIN) must be discovered manually, which makes
maintenance a little more difficult. The warning in the server log does
make it fairly easy to fire up an early build of a new server version
and check if everything initializes correctly.
2021-07-30 18:21:41 +02:00
Andreas Troelsen 95b65371f1 Switch to Spigot API and bump version to 1.17.
Spigot has decided to discontinue distribution of the Bukkit artifacts,
which means Bukkit "doesn't exist" after Minecraft 1.15. This commit
takes the plunge on that change and moves to the Spigot API rather than
the Bukkit API. Goodbye, Bukkit. Hello, Spigot.

The version is also bumped to 1.17 to give way to new features and bug
fixes otherwise blocked by staying on 1.13. Unfortunately, this brings
with it a swath of potential issues with version compatibility going
forward, because backwards compatibility in the API sometimes takes a
back seat, such as with the Material and EntityType enums. This commit
specifically changes some references that break compatibility with older
server versions, but compatibility with those is reinstated later.

Finally, the Spigot repository is changed to match the consensus about
which path on the Spigot Nexus instance to use. This seems to be what
everyone else is doing, so `bandwagon.jumpOn()`.
2021-07-30 18:21:39 +02:00
Andreas Troelsen f1cfd4136e Update Mockito version.
This makes the test setup compatible with Java 16.
2021-07-07 00:39:59 +02:00
Andreas Troelsen b99713f1ec Add reload events.
This commit introduces two reload events, MobArenaPreReloadEvent and
MobArenaReloadEvent. Both events are fired when MobArena reloads, the
former right before the reload, and the latter right after.

The reason for two events is to allow plugins to reload either entirely
or partially along with MobArena, if it makes sense for them to do so,
_when_ it makes sense for them to do so. Some plugins need to reload and
re-register themselves with MobArena before the config-file itself is
loaded (e.g. ThingParsers), while others either require MobArena to be
fully loaded or are more decoupled and thus don't depend on anything in
MobArena's innards to function. The "pre" event is for the former, while
the other event is for the latter.

As for naming, the choice of "Pre" and no prefix was made for the sake
of consistency with the event names in the Bukkit API, which has just
one example of such a pair (PlayerPreLoginEvent and PlayerLoginEvent).
Some event naming conventions (e.g. in the .NET world) seem to favor
present and past tense (reloading, reloaded), but this would be wildly
inconsistent with the rest of the event names, so it might be better to
just stay consistent. Names may change before an actual release, but for
now, this is what we're rolling with.

Closes #677
2021-07-07 00:14:29 +02:00
Andreas Troelsen 903752d23a Add support for registering subcommands by instance.
This commit introduces a new `register()` method on the CommandHandler
class to allow registering pre-instantiated subcommands. This means that
subcommands are no longer restricted in terms of instantiation, so they
can have their dependencies injected at creation, rather than having to
resort to Singleton anti-pattern means.

Also refactors the existing internal MobArena command registration to
use the new method to "drink our own champagne" and to reuse the code.

Fixes #675
2021-07-01 22:59:05 +02:00
Andreas Troelsen 614da20df8 Make `/ma playerlist` pattern less greedy.
This commit changes the pattern of the player list command to one that
isn't quite as greedy. This change is enough to fix issue #676 and thus
allow MobArenaStats to take control of its own command.

The command framework could definitely do with a bit of a rework away
from pattern matching towards aliases, which would prevent similar
issues from cropping up down the line. For now, this is good enough.

Fixes #676
2021-07-01 22:57:21 +02:00
Andreas Troelsen 2c2c36b880 Bump version to 0.106.1. 2021-05-10 09:08:19 +02:00
Andreas Troelsen 498cef9ec7 Release 0.106. 2021-05-10 09:07:50 +02:00
Andreas Troelsen 30c059f51b Include bStats, Github Actions in changelog.
These should have been included in their respective commits, but they
didn't seem particularly interesting for end users at the time. Might as
well include them, though.
2021-05-09 13:43:55 +02:00
Andreas Troelsen b08c74afbd Replace Travis CI with Github Actions.
This commit introduces a Github Actions workflow in the form of the file
`.github/workflows/build.yml`, replacing Travis CI and its `.travis.yml`
file.

The new workflow does a little bit more than Travis CI: it uploads an
artifact after a successful build. Due to a known issue with Github's
package UI, the MobArena.jar file is dynamically zipped on download, so
we get MobArena.jar.zip containing just MobArena.jar. It's redundant,
but there doesn't seem to be a simple way around it at the time of this
commit, so we'll leave it be.

For now, the workflow runs on every push to every branch. I'm probably
going to regret that, but we'll leave that as it is for now as well.
2021-04-15 17:24:56 +02:00
Andreas Troelsen c7e740040c Update bStats Metrics to 2.2.1.
The previously nested classes are now standalone, so imports and super
class definitions of the custom various charts are updated as well.
2021-04-11 13:11:47 +02:00
Andreas Troelsen 9081ec8055 Add support for custom formulas.
This commit re-frames the formula concept used by the wave growth, swarm
amount, and boss health wave configuration properties. It fundamentally
changes how these values are calculated, from a static, compile-time set
of enum values and hardcoded expressions, to a powerful math expression
feature that supports constants, variables, operators, and functions.

In part to remain backwards compatible with existing MobArena setups,
and in part for a better user experience, the old enum-based expressions
are relocated into a new file, `formulas.yml`, as _macros_. The file is
written to the plugin folder if missing, and it contains a formula for
each of the legacy values for each of the enums. Additionally, it has a
global section with some predefined macros for inspiration's sake. The
goal of this file is to allow people to define new formulas and reuse
them in their wave configurations instead of having to duplicate the
same formulas again and again.

Parts of the system are extensible. It is possible for other plugins to
register additional constants, variables, operators, and functions.

Closes #460
Closes #461
2021-04-07 22:13:03 +02:00
Andreas Troelsen 0da90f3963 Rework arena sign data store.
This commit constitutes a major rewrite of how arena signs are stored
and loaded. It fixes an issue where an unloaded or missing world would
cause MobArena to throw errors if there were any arena signs recorded in
said world.

The solution is to load signs of a given world when it is available,
rather than loading all signs at once indiscriminately. At startup,
signs for all _currently available_ worlds are loaded. This fixes the
errors. When a world loads and a WorldLoadEvent is fired, signs in that
world are loaded. This ensures that all valid signs in existing worlds
will _eventually_ load. To keep things tidy, a WorldUnloadEvent will
unload all signs for the unloaded world.

Bukkit's own YAML deserialization implementation doesn't re-throw all
deserialization errors, which means we can't actually catch the problem
of missing worlds without doing an awkward "scan" of the deserialized
objects. This prompted a rewrite of the serialization and data storage
into a custom CSV-like format which is both simpler and also provides a
lot more control over the process. Instead of relying on world _names_,
the new format uses world _UUIDs_. While the rest of the plugin won't
necessarily adapt well to a world being renamed, the signs data store
should be resilient enough to handle it.

Most of the actual sign rendering code and almost all of the template
code is intact, but quite a lot of other classes have been rewritten or
replaced. Some of the rewrites weren't strictly necessary, but because
the components were already fairly small, rewrites were much faster and
a lot less awkward than attempting to adapt existing code.

Fixes #645
2021-03-25 10:20:49 +01:00
Andreas Troelsen cf296704b0 Clean up .gitignore.
This file has an interesting history with content that goes all the way
back to MobArena's dark days of both Ant and Eclipse. This commit cleans
up the file a bit, removing a lot of unnecessary bits and pieces, and
making it a little more tightly bound to the current project setup.
2020-11-08 19:27:22 +01:00
Andreas Troelsen 9bc23c61a0 Bump version to 0.105.1. 2020-11-08 18:34:37 +01:00
Andreas Troelsen 3bef4948a6 Fix date of 0.105 release in changelog.md.
Time flies, oh my!
2020-11-08 18:33:18 +01:00
Andreas Troelsen 5f62b8013b Release 0.105. 2020-11-08 17:35:31 +01:00
Andreas Troelsen 532a2ce0da Add Maven Wrapper.
This should make it a lot easier to get started with the project and to
build a custom artifact from source.
2020-11-04 01:21:50 +01:00
Andreas Troelsen 07f0ce5d08 Add changelog entry for water bottle fix on 1.8.
This is a bit awkward to deal with, because the actual fix exists only
on the 1.8 branch, but we release from the main branch, so we want the
changelog entry to come from there.
2020-11-04 01:12:27 +01:00
Andreas Troelsen d960aebbb0 Reformat changelog for upcoming changes.
Rearranges and reformats the changelog entry for the upcoming version to
better fit with the Keep a Changelog guidelines. We're already grouping
stuff decently, but we can do better with section headers. In an entry
like this one with lots of changes, it just makes the reading experience
much better, and we do want people to read the changelog :)
2020-11-04 01:09:28 +01:00
Andreas Troelsen 4ceb5b7bec Allow use of "config name" in `default-class`.
This is a very simple change that could potentially save a lot of
headaches when people look elsewhere in their config-file and see a
class name like "Big Gary" and wonder why putting that value in the
`default-class` property won't work.
2020-11-04 01:05:53 +01:00