Commit Graph

1050 Commits

Author SHA1 Message Date
Andreas Troelsen
7288fc566b Return class name slugs in MobArenaHandler. 2020-11-03 19:58:30 +01:00
Andreas Troelsen
31282014b3 Use slugs internally in Upgrade Waves.
This just removes the internal use of "lowercase name" in Upgrade Waves
and _should_ have no effect on the actual config-file and the parsing
done there.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
2a87aef9f3 Use class "config name" on leaderboard signs.
Same as with arena names, we can just use the class "config name" on
leaderboards for a prettier experience.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
06cedde031 Allow multi-word names in /ma addarena and /ma autogenerate.
Introduces support for multi-word arena names in the two commands. The
approach is to simply join the arguments by spaces. Because of the new
slug-based lookups, multi-word names are fairly straightforward.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
0f93d8ac05 Resolve arenas by name using slugs.
This commit is a minor refactor of how arenas are resolved by name,
similar to the previous arena class resolution refactoring.

The difference this time around is that there is an ArenaMaster method
that does most of the work for a lot of different areas of the plugin,
`getArenaWithName(String)`. This method is called from well over 30
different places in the code base, making it a cornerstone of all arena
resolution. Luckily, it is called primarily from places that shouldn't
care _how_ an arena is resolved.

Affected by this commit are all commands that resolve arenas by name,
including all those not listed in the diff, because of the change to
`getArenaWithName(String)` on ArenaMaster.

Commands that can tab complete arena name arguments now complete slugs
instead of config names.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
fdb84dfaf4 Use Arena "config name" on leaderboard headers.
Going forward, it should be possible to show "pretty" arena names by
simply using a pretty name in the config-file instead of slug-like names
now that slugs are on the horizon.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
f10c7e464c Deprecate Arena arenaName() method.
Conversely to how the "lowercase name" of ArenaClass was deprecated in
favor of the slug, the "arena name" method here is deprecated in favor
of the "config name" of arenas. Instead of trying to pretty up an arena
name (which is doomed to fail), we just use the "config name" for pretty
printing instead, and start using slugs elsewhere.

This should give way to a much better experience with multi-word arena
names as well.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
037c2ffa43 Use arena class "config names" in /ma autogenerate.
Swaps the weird "camel casing" approach in the autogenerate command out
with simply using the "config name" of the arena classes when creating
class selection signs.

This fixes the breaking change to how classes are resolved in a previous
commit, but only in future arena generation procedures. Arena generated
before this change may still contain broken class signs.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
5bcab8fa46 Use arena class slugs for class selection.
This commit is a minor refactoring of the class selection functionality
plugin-wide. Instead of selecting classes based on the "lowercase name"
of a class, commands and listeners are now "slug aware", as it were.

The ArenaClass class now uses its slug instead of its "lowercase name"
for equality and hash codes.

The `/ma class` command now tab completes slugs, but it still supports
class names as they appear in the config-file when executing the command
itself. The same applies to the `/ma classchest` command.

The sign handling in ArenaListener slugifies sign text instead of just
lowercasing and stripping spaces.
2020-11-03 19:58:30 +01:00
Andreas Troelsen
519886cf3e Use slugs in arena and class permission checks.
This commit changes the permission checks for arenas and classes to a
slug-based approach instead of the "config names", which are somewhat
arbitrary and may contain spaces, which are generally not supported by
permissions plugins.

This is a breaking change, which means it will be necessary for users
to change their permission setups. Backwards compatibility could have
been implemented, but it just leaves more room for ambiguity and will
make a necessary transition later down the road less obvious. Instead,
we burn the ships!

As a result of this change, access to the "My Items" class can now be
revoked as intended with the key `mobarena.classes.my-items`.

Fixes #647
2020-11-03 19:50:29 +01:00
Andreas Troelsen
1b46e17e38 Deprecate ArenaClass getLowercaseName() method.
This commit deprecates the "lowercase name" method on ArenaClass to push
the new slug concept throughout the code base in a "healthy" way.
2020-11-01 14:28:40 +01:00
Andreas Troelsen
aed57f5cb6 Introduce slugs in arenas and classes.
Whitespace and punctuation in identifiers is a fairly big source of
issues in areas like permissions and commands where whitespace isn't
directly supported (or at least makes things needlessly difficult).

This commit introduces the concept of a "slug" in arenas and classes,
giving them a _consistent_ `kebab-case` name for use in such places, but
it does not implement their use anywhere. Slugs are expected to be the
solution to problems like the one posed in issue #647.

At the time of writing, we're only concerned with simple stuff like
removing periods, commas, parentheses and replacing underscores and
spaces with dashes. If it turns out that people have unanticipatedly
problematic arena and class names, we may have to expand the slug
definition rules or allow for custom slugs.
2020-11-01 14:28:33 +01:00
dependabot[bot]
5ebdf45f6a
Bump junit from 4.12 to 4.13.1
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-13 04:37:10 +00:00
Andreas Troelsen
efc66820c6 Add specific Msg value for /ma addreward.
This commit introduces a new announcement value for the `addreward`
command. This allows server owners to completely remove the message by
setting it to the empty string while retaining wave reward messages.

In general, we shouldn't reuse announcements unless the actions that
send them are identical, because it makes everything a lot more tangled
than it has to be.
2020-09-19 10:57:17 +02:00
Andreas Troelsen
dafae0cf07 Add /ma addreward command.
This command takes an arena player and a Thing as input. The Thing is
parsed in the same way as all other rewards are parsed, so it supports
the new `all()` and `random()` functions and the `nothing` keyword.

The "target audience" of the command is mainly scripts. It opens up the
possibility of hooking into MobArena's rewards from command blocks or
other plugins, but with very low coupling.

Closes #643
2020-09-19 10:32:03 +02:00
Andreas Troelsen
3b132d28dd Use ThingPicker for boss rewards.
By using a ThingPicker instead of a Thing, boss rewards can now, just
like regular wave rewards, make use of the new `random()` and `all()`
functions as well as the `nothing` keyword.

Closes #628
2020-08-24 22:53:00 +02:00
Andreas Troelsen
d30bd96a2a Add support for picking nothing.
This commit introduces the strange concept of a singleton ThingPicker
that only ever picks `null`. The purpose of this picker is to allow for
a type of "loot table" experience similar to that found in other games.
An example would be a piece of equipment that only has a 50 % chance of
dropping. With the current state of MobArena, it would be necessary to
something conjure up a CommandThing or something to emulate nothingness,
but now there is native support for it with the `nothing` keyword.

The nullability of rewards also has the side effect that we got to clean
up the MASpawnThread `addReward` method a bit.

Closes #638
2020-08-22 17:36:30 +02:00
Andreas Troelsen
994ebaff81 Allow for reward grouping.
This commit makes the MAUtils class responsible for parsing reward maps
use the new ThingPickerManager to parse the reward lists. As a result,
the new `all()` and `random()` pickers are available for use in the
rewards section.

This should allow for granting item sets and similar types of "bundles"
as rewards in the arena, e.g. a diamond sword and permission to join a
more difficult arena.

Closes #386
2020-08-22 17:12:29 +02:00
Andreas Troelsen
bff1ab5694 Convert rewards to the new ThingPicker framework.
This commit makes breaking changes to the Arena interface to switch to
the new ThingPicker framework for rewards. It is unfortuante that the
Arena interface has so many disparate responsibilities that changes like
these are necessary on such a central component when the change itself
is actually very isolated to just rewards handling.

With this change, rewards are now wrapped in pickers, which should give
way to some grouping and "well-defined entropy".
2020-08-22 17:12:29 +02:00
Andreas Troelsen
dd54f70682 Add ThingPickerManager to main plugin class.
Introduces the ThingPicker framework to the plugin by bootstrapping a
manager for it in the main plugin class. By default, we're just running
the group and random picker parsers, but other plugins should be able to
hook in with their own parsers.

Nothing actually _uses_ the pickers yet, but that's next on the menu.
2020-08-22 17:12:29 +02:00
Andreas Troelsen
2d0aad19d6 Add ThingPickerManager.
This little nugget is what we will wire up in the main plugin class once
we're ready to introduce it to the code base for real. Its purpose is
similar to that of the ThingManager, in that it _is_ a parser and can be
passed around wherever a parser is needed, but it also is the main entry
point for anything that is ThingPickerParser instances.
2020-08-22 17:12:29 +02:00
Andreas Troelsen
5566d8fd86 Introduce ThingPickerParser.
To ensure that we are extensible from the get-go, this commit introduces
the parser aspect of the ThingPicker framework with parsers for the two
non-trivial picker implementations.

Nothing is wired up yet.
2020-08-22 17:12:26 +02:00
Andreas Troelsen
e8bb8a9e4d Introduce ThingPicker.
Things work best as hardwired, atomic pieces of "stuff", so fitting RNG
into the framework is a little difficult. We could have a RandomThing,
but the issue with that is that the entropy has to live inside of it for
it to be random every time it is given, taken, or checked. This makes it
impossible to make a well-defined, atomic Thing with entropy involved.

Enter the pickers.

The ThingPicker is an early stage extension to the Things framework that
encapsulates the possibilities of entropy and grouping _around_ Things,
a type of Factory pattern.

This introductory stage consists of a "leaf picker" that can only ever
pick a single Thing, a Composite Pattern "group picker" that wraps a
list of other pickers and shoves their resulting Thing instances into a
ThingGroup (introduced in the previous commit).

These simple constructs should now make it possible to introduce entropy
without placing the responsibility on the Thing framework itself. Using
this extension requires adapting code to using the ThingPicker interface
instead of using Thing directly.
2020-08-22 16:10:07 +02:00
Andreas Troelsen
e1784552de Add ThingGroup.
Introduces a group of Things as a construct for bundling Things that
should constitute a single unit for whatever reason.

One reason could be to make an _item set_ an atomic reward, e.g. a set
of diamond tools for beating the `workshop` arena. Instead of having to
spread the rewards out into multiple waves or use a different plugin to
create item groups, this component allows MobArena to support that kind
of intent natively.

Note that nothing is wired up in this commit, so really this commit is
just introducing unused code.
2020-08-22 15:00:11 +02:00
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
31010c1576 Initiate player leave when spectate-on-death: false.
Errata to commit 84a7a2ed8a.

The protocol after the join/leave process rework was:

- `spectate-on-death: true`: leave, then spec
- `spectate-on-death: false`: leave

The protocol now is:

- `spectate-on-death: true`: spec
- `spectate-on-death: false`: spec, then "leave"

I put "leave" in quotes, because _discarding_ the player here does not
invoke the part of the leave protocol that tries to ensure teleports go
through according to plan. By capitalizing on the "leave" part, making
it explicit that that's what we're doing in the next tick after warping
the player to the spectator area, we return to the form of the original
rework where we use coarser-grained state control to make things easier
to reason about.

A side-effect of this change is that if players somehow manage to kill
themselves in the lobby, they will be refunded the entry fee.
2020-08-22 09:42:45 +02:00
Andreas Troelsen
514c03dad0 Strip trailing whitespace; add missing newlines.
This promiscuous commit goes around touching almost every file in the
repository with the intention of removing trailing whitespace and adding
newlines to files missing them.

Trailing whitespace has been a pain for along time, especially in terms
of contributing to the project without accidentally littering commits
with whitespace stripping, so this commit is long overdue.

As for the newlines, well, the script I found on StackOverflow to strip
trailing whitespace also happened to add missing newlines, which is
something I wanted to tackle anyway, but in a different commit. It's all
good though.
2020-08-21 00:23:14 +02:00
Andreas Troelsen
043d970593 Remove obsolete TODOs.
Some of them have been mangled somehow, and others just straight up
aren't relevant anymore. Tidy up!
2020-08-20 23:45:07 +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
684116918a Remove nexus.hc.to repository from pom.xml.
Jitpack is the recommended Vault repository now, and we've actually
already updated the comment for Jitpack to include Vault previously, so
let's just get rid of the HeroCraft repo now.
2020-05-31 21:09:13 +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
Andreas Troelsen
58cb29ae97 Remove obsolete class comment in Root Target.
For some reason, this is the only ability that has such a comment, and
it doesn't really provide any value, so yeet.
2020-05-04 07:59:57 +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
Andreas Troelsen
ce9f07e6b5 Remove docs folder.
This commit nukes the readthedocs documentation from the repository, but
it is kept as a local backup.

The RTD effort was a valiant one, but it fell by the way side, mostly
due to a lack of attention from my part. At this point in time, the wiki
and RTD have diverged too much, and I would rather have just one place
for documentation than two that are out of sync.

If we ever pick up RTD again, it's probably going to be with a complete
documentation rework in mind.
2020-04-25 21:59:23 +02:00
Andreas Troelsen
787f1120d1 Remove readthedocs status from README. 2020-04-25 21:57: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
Andreas Troelsen
8426be46fb Tidy up SheepBouncer.
This was getting on my nerves.
2020-04-09 11:39:23 +02:00
Andreas Troelsen
9245e53509 Mark constants in abilities static.
No need to have instance-local constants.
2020-04-09 11:37:30 +02:00
Andreas Troelsen
c9b0f85bee Remove unused fields, imports, warning suppressions.
Just a bit of spring cleaning!
2020-04-09 11:31:46 +02:00
Andreas Troelsen
299a16ca8c Remove old, unused Updater class.
This was superseded by the PluginVersionCheck class and hasn't been in
use since the beginning of 2020.
2020-04-09 11:28:59 +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