Fragments: Separate out item bans (#1595)

* Remove commented out warning disable

* Add initial ItemBans segregation infrastructure

* Add shell for initial OnSecondUpdate stuff

* Add comments yo

* Remove duplicated logic

* Split out more item ban code

This part of the fragments work is primarily aimed at reducing the
complexity of OnSecondUpdate in TShock and moving that check out into
the ItemBans subsytem.

Of major note in this is the removal of "check", which was a string
variable that tracked state and replacement of many of the item ban
activities with sane private methods that are at least somewhat
sensible. Obviously there's a lot to be desired in this system and I'm
really going for a run here by trying to continue a branch from so long
ago that I barely even remember the whole point of existence.

Still to do: GetDataHandlers related item ban code needs to be moved
into its own hook in the ItemBan system. Finally, there is a downside to
some of this: we're basically iterating over players again and again if
we keep this pattern up, which is kinda lame for complexity purposes.

* alt j: comment changes

* Move item ban check out of main playerupdate check

Separates out item ban logic from the rest of GetDataHandlers so that
item bans is more isolated in terms of what fragments is asking for.

* alt-j: convert indentation to tabs

* alt-j: fix botching source code

* Move item ban related chest checks out of gdh

* Remove chest item change detection from item bans

It doesn't do anything. If a user removes an item from a chest, it
bypasses this check. If a user adds an item to a chest, the server seems
to persist the change anyway, even if the event is handled. That's a bug
for sure, but fundamentally, it's not the item ban system's fault.

* Revert "Remove chest item change detection from item bans"

This reverts commit 758541ac5c4d4096df2db05ba2a398968113e1e4.

* Fix logic issues related to item ban handling

Re-implements chest item handling and correctly handles events and
returns after setting handled event state.

* Remove TSPlayer.HasProjectilePermission

In infinite wisdom, it turns out this is not a good method for TSPlayer
to have. It just checks the states of things as per what the item ban
system says is banned and then creates implicit relationships to the
projectile ban system.

Doing this effectively knocks down another external reference to the
item ban system outside of the context of the implementation for the
system itself and its related hooks.

This commit also adds context around what the heck is going on with some
of our more interesting checks as per discussions in Telegram with @Ijwu
and @QuiCM.

* Update changelog

* Remove useless ref to Projectile.SetDefaults

* Change item ban to ban based on ID not strings

I think I was so confused as to why we were passing strings everywhere
that I just felt inclined to continue the trend in previous commits.
This commit is contained in:
Lucas Nicodemus 2020-05-16 16:27:34 -07:00 committed by GitHub
parent ab99c48212
commit b5f95d5918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 292 additions and 144 deletions

View file

@ -41,7 +41,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Added `GetDataHandlers.PlaceObject` hook. (@hakusaro)
* `GetDataHandlers.KillMe` now sends a `TSPlayer` and a `PlayerDeathReason`. (@hakusaro)
* Added `GetDataHandlers.ProjectileKill` hook. (@hakusaro)
* Removed `TShock.CheckProjectilePermission` and replaced it with `TSPlayer.HasProjectilePermission` and `TSPlayer.LacksProjectilePermission` respectively. (@hakusaro)
* Removed `TShock.CheckProjectilePermission`. (@hakusaro)
* Added `TSPlayer` object to `GetDataHandlers.LiquidSetEventArgs`. (@hakusaro)
* Removed `TShock.StartInvasion` for public use (moved to Utils and marked internal). (@hakusaro)
* Fixed invasions started by TShock not reporting size correctly and probably not working at all. (@hakusaro)
@ -90,7 +90,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* `Utils.TryParseTime` can now take spaces (e.g., `3d 5h 2m 3s`) (@QuiCM)
* Enabled banning unregistered users (@QuiCM)
* Added filtering and validation on packet 96 (Teleport player through portal) (@QuiCM)
* Update tracker now uses TLS (@pandabear41)
* Update tracker now uses TLS (@pandabear41)
* When deleting an user account, any player logged in to that account is now logged out properly (@Enerdy)
* Add NPCAddBuff data handler and bouncer (@AxeelAnder)
* Improved config file documentation (@Enerdy)
@ -98,6 +98,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Update sqlite binaries to 32bit 3.27.2 for Windows (@hakusaro)
* Fix banned armour checks not clearing properly (thanks @tysonstrange)
* Added warning message on invalid group comand (@hakusaro, thanks to IcyPhoenix, nuLLzy & Cy on Discord)
* Moved item bans subsystem to isolated file/contained mini-plugin & reorganized codebase accordingly. (@hakusaro)
## TShock 4.3.25
* Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.