garbagemule / MobArena

MobArena plugin for Minecraft
GNU General Public License v3.0
189 stars 150 forks source link

New Feature: [re]join a running game #771

Open tadhunt opened 9 months ago

tadhunt commented 9 months ago

Summary

I run some servers with MobArena for young children, and one of the most often voiced complaints is that once they die they have to wait until the game ends before they can rejoin. There is already a issue tracking this request with some interesting discussion about the challenge. I'm not sure whether this addresses the full set of challenges described there, but it works very well for our use case.

Problem

Solution

When the settings.rejoin config file option is enabled (true), startArena() has been updated to run through the set of things it needs to do to add a player to the game, without doing all of the "start the arena" stuff. That new code is self contained in a new function, addReadyPlayers() and is only called when the arena is already running (and the rejoin feature is enabled).

Additionally, the scoreboard ended up with duplicate entries for rejoined players (one greyed out and one not), so I've also updated the scoreboard logic to only do the "fake" weirdness (which I don't really understand) if rejoin is not enabled. This seems to do the trick (except dead players that don't rejoin won't get greyed out, I guess).

In addReadyPlayers(), I also needed to add the player to any active bosses healthbars, otherwise the healthbar wouldn't show up when they rejoined.

Action

Review & playtesting would be much appreciated. I suspect based on the reading of #664 that there are likely to be interactions with other features which don't work correctly. However, we haven't noticed any issues with the basic features we're using (pretty much a stock config).

You can find the build from the github action here: https://github.com/tadhunt/MobArena/actions/runs/6132540696

I've only tested this PR in a branch that also contains #769 since all of my development and testing is on top of that, so if that PR doesn't get integrated, it's worth doing some more playtesting with just this PR to make sure there aren't any lingering issues.