garbagemule / MobArena

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

Add a config to choose in what order MA gives rewards & teleports #639

Open LaBarata opened 4 years ago

LaBarata commented 4 years ago

Feature request

Short description

We should have a config to allow server owners to choose when the rewards will be given, either before or after the teleport back.

Implementation details

It would allow owners to have arenas in other MultiVerse worlds with separate inventories and allow them to keep their rewards in other MV worlds.

Additional info

garbagemule commented 4 years ago

I really don't like the idea of making the order too configurable. It has the benefit of giving full control to server owners, but chances are they won't know what they're doing half of the time. This is not a jab at server owners. The join/leave protocol is complex and is ordered the way it is for a reason (lots of trial and error and plugin conflicts), and opening it up entirely would be a support nightmare, because people would shift everything around and make the behavior of the plugin unpredictable.

However, this should be possible to do in a straightforward way if we limit the possibilities to the current functionality ("before teleport") and "after teleport". If so, it would be a matter of a couple of if statements in the join step factory. I think the way to do it would be to have a new config setting, grant-rewards-after-teleport, which is false by default, but can be changed to true.

Here is the line in the step factory for the join process: https://github.com/garbagemule/MobArena/blob/514c03dad0d0716e5069017dcab654ce63da24e8/src/main/java/com/garbagemule/MobArena/steps/PlayerJoinArena.java#L21

This line would need to be wrapped in an if statement ("if grant-rewards-after-teleport is false"). Furthermore, it would have to be duplicated above all the other steps, and the expression in the if statement negated ("if grant-rewards-after-teleport is true). Because of the mutual exclusion inherent in the boolean data type, this would put the deferred GrantRewards step either where it currently is or above everything else (after everything else in the leave process). This is still pretty straightforward to reason about, so I think it's acceptable.

I think this issue is very easy to implement and test, so I would love to give someone else the opportunity to do so. I can't say if it will be included in the 0.105 release or not, but we could probably run some test builds on Discord :)