Block other plugins' portals, signs, etc.
pgmann opened this issue ยท 2 comments
--- Imported from dev.bukkit.org: original issue reported by TheOnlyRealTGS ---
If possible, it would be cool if you could block entering the War plugin's portal (currently you can enter the game while in spectate mode), clicking Hunger Games join signs, and generally just prevent joining other minigames because it messes a lot of stuff up.
Maybe you could make a list of negated permissions in the config file? Then you would be able to put -hg.*
and therefore the players wouldn't be able to join Hunger Games.
Task List
- Permission removal
- Store player permissions when
Spectator.enableSpectatorMode()
is called in some kind of List, then remove them from the player. - Handle permissions being added/removed by other plugins or
op
/deop
during spectate. - Make sure the permissions are added back when
Spectator.disableSpectatorMode()
is called, and the old list gets emptied. - Don't remove permissions if the player has an admin bypass permission granted, called
spectate.admin.bypasswhitelist
(existing permission, maybe split intospectate.admin.bypass.whitelist
andspectate.admin.bypass.permissions
?) - Don't ever remove SpectatorPlus permissions, as they don't need to be.
- Store player permissions when
- Cancel click events
- Bind to click events and cancel them all if the player involved is spectating (use
LOWEST
priority to cancel before other plugins have a chance to process the event, but they could still ignore this).
- Bind to click events and cancel them all if the player involved is spectating (use
- Handle teleportation events
- Cancel teleportation events not made by SpectatorPlus or a command (any other cases?) using
HIGHEST
priority. - Check for a teleport which has happened anyway and bring the player back to their original location 1 tick later. This could be done using
MONITOR
priority as we will normally just be looking on or firing our own event.
- Cancel teleportation events not made by SpectatorPlus or a command (any other cases?) using
--- Imported from dev.bukkit.org: orginal comment by AmauryPi (@AmauryCarrade) ---
Summary of my ideas to close this ticket
It is possible to change the permissions of the players.
We just have to store for each player the permissions effectively removed, and to add them back later, filtered by a list set in the configuration file.
Maybe only if the player does not have the permission spectate.bypassPermissionRestriction
(or similar, the name isn't the point here).
As a failsafe, we can cancel the clicks on the signs and the non-SpectatorPlus teleportations.
Cancelling signs clicks is quite simple (with a LOWEST
priority to cancel it before the other plugins), but the plugins needs to check if the event is cancelled. It is not technically possible to stop an event propagation (it is only possible to mark it as cancelled), or to block other plugins in a general way.
I can also cancel any teleportation not made by SpectatorPlus and not manual (with /tp).
Either using event.setCancelled(true)
, or with a TP-back one tick later (to avoid the case of plugins ignoring the cancel state of an event), all of this with a HIGHEST
priority.
I think these three cases would cover a lot of cases. BUT, there is also another problem: if a spectator is marked as a player by a plugin (i.e. registered by the plugin), I can't cancel this registration.
Except of course by removing the permissions.