TownyAdvanced / Towny

Towny Advanced Minecraft plugin for Bukkit/Spigot.
https://townyadvanced.github.io
Other
526 stars 352 forks source link

Suggestion: PlayerBedUse event #6310

Closed lexiccn closed 1 year ago

lexiccn commented 1 year ago

Please explain your feature request to the best of your abilities:

There is an event for PlayerDeniedBedUse which is very helpful; however this requires it to fail already

If it passes but there is a reason to cancel; such as: Combat tagged (CombatLogX) In a siegezone (SiegeWar)

Then there is no event to do anything with

I guess there is a few ways to handle this;

  1. Send PlayerDeniedBedUse always; but cancel it if it should pass - Could cause issues with current use of it though; since it assumes it was cancelled
  2. Add PlayerSuccessBedUse or something along those lines; however not sure if there's a good way to make that send a Denied one for back-compat if it fails
  3. Add PlayerTriesBedUse event - If cancelled; check if DeniedBedUse is true? Something like that I guess?

It's not really that unreasonable to just have the same checks in my own plugin; but it would be nicer to integrate with Towny already doing it

LlmDl commented 1 year ago

This event started getting listened to backwards semi-recently. It will behave correctly in teh next pre-release but if you need something to test with 0.98.3.0 would also work correctly.

Nevermind it wasn't broken.

LlmDl commented 1 year ago

I think a PlayerSetBedSpawnPointEvent might be ideal, which would not throw if PlayerDeniedBedUseEvent has happened.

Warriorrrr commented 1 year ago

The PlayerEnterBedEvent could just be used instead of us adding a new event, it won't fire if we cancel the interact event.

LlmDl commented 1 year ago

That too.

lexiccn commented 1 year ago

The reason that doesn't work for this is Respawn Anchors; they don't throw an event on their own that I can find; hence would need identical checks to Tagged BED || DisallowedAnchorClick thing to get it

LlmDl commented 1 year ago

Not saying we wont add one, but this is really a suggestion for the Spigot team: a PlayerSetSpawnEvent to go into https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/package-summary.html

Warriorrrr commented 1 year ago

Paper also already has that if you're targeting that: https://jd.papermc.io/paper/1.19/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.html

lexiccn commented 1 year ago

Thank you - for what I'm doing yeah I am; I don't know how I've apparently missed that repeatedly while using Paper javadocs

I'll leave this open because it might still be useful for non-Paper servers or Towny Addons like preventing in war either way/admin here can close