Improve Bans API. Add Whitelist API #954
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SpongeAPI | SpongeCommon
This PR improves the Bans API, correcting several issues preventing it from being implemented properly.
Notable changes:
BanType
enum has been replaced with the standard pseudo-enum classes (BanType
andBanTypes
)GameProfile
s instead ofUser
s. AUser
has associated world data, which is not applicable forBan
s.GameProfile
orInetAddress
can have exactly one ban. The previous concept of multiple bans per user/IP was a significant departure from Vanilla, and had no real use-casesBanData
andWhitelistData
references have been removed. This was a redundant way of accessing theBanService
, and made it too easy for plugins to overwrite existing bans.Ban#getStartDate
has been changed toBan#getCreatedDate
. While the date is present in Vanilla, it only serves as an informational value. Making it function as a proper start date would break Vanilla compatibility, or introduce a disparity between the internal handling of Bans versus theBanService
WhitelistService
. This is much simpler thanBanService
, as Vanilla whitelist entries lack the complexity of ban entries (no start/expiration date, source, orInetAddress
target)ClientConnectionEvent.Login
is now fired already cancelled, if the player would be unable to join due to a ban/lack of whitelist/server being full.Both
BanService
andWhitelistService
fully support replacement. However,SimpleServiceManager
still needs to be updated to allow services to be replaced.TODO:
ClientConnectionEvent.Join
. This could be in the form of a specificCause
object (similar toSpawnCause
), or 'getOriginalXXX, getXXX, setXXX
methods on the event.