TehBrian/NoBedExplosions

multi-world support

Closed this issue · 2 comments

From the plugin's page on SpigotMC, this is a review from LadyHaley:

A great addition, thats for the work you put into this. I was really surprised when i realized that this functionality wasn't native in world guard. if you felt like adding more functionality into the plugin i would suggest adding multi world support, and have the functionality toggleable for all worlds active on the server!!!

I agree! That seems like a really useful feature, because, for example, someone might want to be able to let their players sleep in the nether, but not the end.

The main challenge is coming up with a good config. It shouldn't be redundant or confusing but it still needs to allow for complete configurability.

Here are the requirements for the config:

  1. It's not just the nether or the end that needs to be configurable, as users might have multiple worlds. Rather, it needs to be configurable by the world's name.
  2. PER WORLD you need to be able to specify if you want to allow sleep, deny sleep, or disable the plugin's functionality (explode/regular functionality).
  3. PER WORLD you need to be able to specify the message that gets sent to players if they're denied sleep. The message also needs to be able to be turned off.
  4. (possibly) You need to be able to turn the entire plugin's functionality off, for testing purposes.

Let's say I'm a server owner. I have 4 worlds. world_the_end, super_world, insomnia_world, and explosions_everywhere.

In world_the_end I want the players to be able to click the bed, but they get sent a message such as "You can't sleep here!"
In super_world I want the players to be able to sleep in the bed, get their spawn set, all that nice overworld functionality but in this world.
In insomnia_world I want the players to be able to click the bed, but nothing happens. This would most likely be accomplished by denying sleep and turning the message off.
In explosions_everywhere I want the players to be able to click the bed, and the bed explodes, like in vanilla if you're in the nether or the end.

The plugin needs to be able to cover all of those use cases.

All in all, there's going to need to be some compromise. The name of the game is finding the best route.

With the example of a server owner above, this brings up an interesting question to me. What if it's a world that is the overworld dimension, and not the nether or the end?

What if you want to be able to deny sleep or make the beds explode but in a world that is the overworld dimension?

I'm guessing this would be accomplished by ignoring BedEnterResult and regardless of what dimension we're in:

  • If the config says that the world has beds that explode, we set BedEnterResult to NOT_POSSIBLE_HERE.
  • If the config says that the world has beds allow sleep, we set Event.Result to ALLOW. However, if we ignore BedEnterResult, this would allow players to sleep if, say, it's day time, or there are mobs nearby. This means that we need to specifically check that BedEnterResult is NOT_POSSIBLE_HERE, or OK?
  • If the config says that the world has beds deny sleep, we cancel the event and send the message (or none.)

This begs the question though, is all of this feature bloat? Should NoBedExplosions just focus on what it's doing, which is allowing sleep in dimensions that return BedEnterResult.NOT_POSSIBLE_HERE?

After working on this for a bit, it doesn't seem like there's a way to make beds explode without implementing explosions ourselves, which I don't really want to do. Ideally, we would be able to set BedEnterResult to NOT_POSSIBLE_HERE if the Mode is set to EXPLODE, but alas, we can only set Event.Result, which only has the possibilities of ALLOW, DENY, and DEFAULT.