Commit graph

364 commits

Author SHA1 Message Date
Lucas Nicodemus
195a23a7e5 Migrate most of CheckTilePermission to TSPlayer
TShock.CheckTilePermission(ply, x, y, paint) has been replaced with
TSPlayer.HasPaintPermission and TSPlayer.HasBuildPermission
respectively. These two methods dramatically simplify the logic required
to process build permissions.

Still todo after this commit:

1. Implement warnings for when a player fails a permission check on
build. This is probably going to be accomplished by a default argument
to the HasBuildPermission signature.

2. Create a variant that checks for ice tile permission and use like
HasPaintPermission() so as to remove the other
TShock.CheckTilePermission method.

Annoyingly, all of the existing methods that start with Check seem to
"check" if they player _doesn't_ have permission (true = no permission),
which makes nearly every call negative.
2017-12-22 00:31:02 -07:00
Lucas Nicodemus
09121368e4 Move TShock.CheckRangePermission to TSPlayer
TShock.CheckRangePermission is now TSPlayer.IsInRange, but the most
important thing is that this method returns the opposite of what the
original did, so all of the calls that would go to it are now inverted.
2017-12-21 20:32:07 -07:00
Lucas Nicodemus
97f48d6d41 Renamed TSPlayer.CheckIgnores() -> TSPlayer.IsBeingDisabled()
Since all of the flags it was checking have been demystified, this
is pretty self explanatory now.
2017-12-20 17:42:59 -07:00
Lucas Nicodemus
8e5ee7d286 Renamed IgnoreActionsForClearingTrashCan to conform w/ changes
This just changes IgnoreActionsForClearingTrashCan to meet the
same naming scheme for the rest of the old ignore checks. For
consistency. Consistency is nice.
2017-12-20 17:33:18 -07:00
Lucas Nicodemus
4e186e7375 Replace TSPlayer.IgnoreActionsForDisabledArmor -> boolean
TSPlayer.IgnoreActionsForBannedArmor was useless because it only
stored the last armor/dye a player had. Replaced with a boolean.
2017-12-20 17:29:10 -07:00
Lucas Nicodemus
7efcfd055f Replace TSPlayer.IgnoreActionsForCheating w/ boolean
This replaces IgnoreActionsForCheating in TSPlayer with a new
IsDisabledForStackDetection field that tracks the same basic data.

The previous way we did this was storing a string as the "reason"
why a player was disabled for cheating, but it only stored the last
hacked item stack that caused the check to fail. Since we already
have OnSecondUpdate which notifies on _all_ items, we don't need
to store this info in such a useless way anyway. They'll find out
in one second what they need to remove in a more alarmist way.
2017-12-20 17:19:14 -07:00
Lucas Nicodemus
1ef28dfe0d Replace TSPlayer.IgnoreActionsForInventory => IsDisabledForSSC.
This is the first commit in a series to rewrite CheckIgnores()
into whatever its replacement becomes.

IgnoreActionsForInventory was probably used by the SSC system prior
to when we had in-game support for SSC (ergo, when we just checked
to make sure you had removed all items before joining and worked
our way up in inventory data to track it). I could be wrong about
this though.

Now, IsDisabledForSSC tracks only if a player is shut down due to
SSC, rather than a reason that gets broadcast.
2017-12-20 17:01:55 -07:00
Lucas Nicodemus
c1de974e16 Remove happiness.
http://rubyonrails.org/doctrine

The problem with most programmers is that they refuse to see any
logic in thinking about a problem from the other side, even just
once. You can't argue with someone over what opinionated "programmer
happiness" things are because logically you'll always be outmatched
with "well you can just do it this other way."

Take this example. How is !args.Player.HasProjectilePermission any
easier to understand than args.Player.LacksProjectilePermission?
 -> One is direct: it focuses on what a player doesn't have.
 -> The other is indirect: it's the inverse of have.

You can read one in a sentence and think "so if a player lacks a
permission then this happens" whereas the other is like "invert
if a player has a permission." In this soupy mess of a codebase
where you're trying to sort out what 300 magic numbers mean and
what everything else is trying to do, then it's kinda nice to
be able to read something and understand it immediately.
2017-12-17 01:10:32 -07:00
Lucas Nicodemus
1e9532a316 Create TSPlayer.IsBouncerThrottled() to avoid code copypasta 2017-12-16 01:14:39 -07:00
Lucas Nicodemus
1bee289daf Move TShock.CheckIgnores(TSPlayer) -> TSPlayer.CheckIgnores()
Note: This method really sucks and needs to be rebuilt anyway.
2017-12-16 01:03:05 -07:00
Lucas Nicodemus
ba851d3570 Remove TShock.CheckProjectilePermission
Add TSPlayer.HasProjectilePermission() and its inverse:
	TSPlayer.LacksProjectilePermission()
2017-12-10 23:38:03 -07:00
Lucas Nicodemus
031398591a Merge remote-tracking branch 'origin/general-devel' into fragments 2017-12-09 08:44:49 -07:00
Lucas Nicodemus
eed7b3fad2 Document what TSPlayer.SendTileSquare does 2017-12-09 01:35:27 -07:00
Edgar Luque
6589531868 Renamed TShockAPI.DB 'User' to 'UserAccount' 2017-12-08 01:38:15 +01:00
Lucas Nicodemus
3a8aa7fa29 Brilliant idea: Remove unused code instead of leaving it there. 2017-12-02 14:28:12 -07:00
Ruby Rose
685d9964f0 Change enum names for clarity 2017-07-17 09:06:29 +03:00
Ruby Rose
79f66f554f Turn the player hooks into a tristate 2017-07-17 09:06:29 +03:00
MarioE
ac8fe2a215 Remove netID handling of GiveItem, and provide a smaller overload 2017-07-15 13:32:35 -06:00
Ruby Rose
8ae0a3b5a6 Write proper docs 2017-06-08 17:18:38 +03:00
Ruby Rose
81cb1381b4 Add hooks for item/projectile/tile bans 2017-06-07 15:32:40 +03:00
ZIT WANG
85b0b7bc6a Fix an itemban issue due to localization 2017-04-26 19:26:54 +08:00
White
e1919adfb2 Fixes { and } breaking server message broadcasts 2017-04-25 11:32:39 +09:30
Lucas Nicodemus
9b419467d6
Replace NetworkText.FromLiteral("") with NetworkText.Empty
Thanks @deadsurgeon42
2017-04-20 00:31:33 -06:00
Lucas Nicodemus
2d14533172
Terraria 1.3.5 changes compile (NO GUARANTEES ON EXECUTING) 2017-04-19 18:21:34 -06:00
Lucas Nicodemus
b8dbdb9ff4
Final batch of .name changes 2017-04-19 17:41:15 -06:00
White
c4a3a9fb67 Updated Copyright for 2017 2017-03-13 12:17:16 +10:30
White
86c180c156 Spawning items by ID now actually uses the ID properly.
Fixes #1398
2017-03-13 11:45:32 +10:30
ProfessorXZ
7c8bf7712a Added TSPlayer.Logout() 2016-12-18 12:37:15 +01:00
White
739892a611 Added TSPlayer.KillPlayer() which uses NetMessage.SendPlayerDeath(...).
Changed /kill to use `TSPlayer.KillPlayer()`
2016-12-11 13:46:57 +10:30
Lucas Nicodemus
678f6c7cf8
Update to Mintaka (thanks @enerdy) 2016-12-06 17:36:44 -07:00
Zaicon Kiroshu
50d8b0db30 1.3.4.3 Update (API 1.26) 2016-11-19 17:05:08 -06:00
Hussein Farran
7d323f253a Merge pull request #1321 from DogooFalchion/ssc_join_inv
Enable user to upload their data from when they join as SSC
2016-10-23 20:58:40 -04:00
DogooFalchion
f1ce158efd Implement logic to store the data of a player when they join, and allow for a command to be run that will upload that data in place of their existing SSC data. 2016-10-23 18:11:44 -04:00
Lucas Nicodemus
a0c4864567
Removed all obsolete methods from TShock 2016-10-23 06:09:17 -06:00
Lucas Nicodemus
dce26d6928 Merge pull request #1310 from Simon311/general-devel
Fix for HealOtherPlayer exploit, also fix #1309
2016-10-17 08:51:19 -06:00
Simon
1460a7ad91 Fix for HealOtherPlayer exploit, also fix #1309 2016-10-17 15:51:49 +03:00
Adilson Carvalho
49b4effe74 Changed year to 2016 on all GPL headers 2016-10-16 17:06:02 -02:00
ProfessorXZ
e0f17b82ef SyncExtraValue validation. Fixes #1024 2016-08-10 11:25:03 +02:00
ProfessorXZ
2f57336fe8 Fixes #1252 and #1160, remove the optional parameter from TSPlayer.SendMessage() 2016-07-31 22:33:53 +02:00
ProfessorXZ
d0d0fae5ca Add an optional parameters to SendMessage(), add more XML comments to TSPlayer 2016-07-29 14:11:19 +02:00
ProfessorXZ
a02bc1012d Increase chat length 2016-07-29 11:28:58 +02:00
ProfessorXZ
d5c7dab03d Use packet 107 for sending chat messages 2016-07-29 10:21:24 +02:00
White
ad2f56e251 Added detail to the TSPlayer.HasPermission method comments 2016-07-06 22:06:15 +09:30
Enerdy
dbd6228cc7 Revert "Make TSPlayer.SendMessage use the smart chat packet"
This reverts commit 653f6b834f.
2016-05-29 23:15:48 +01:00
Enerdy
653f6b834f Make TSPlayer.SendMessage use the smart chat packet 2016-05-27 01:00:35 +01:00
White
1a11beded7 Removed readonly from TSPlayer's data field so that it can actually be used 2016-05-18 13:03:17 +09:30
White
457b3d40b3 Changed the GetData<T> and SetData<T> components of TSPlayer, and added RemoveData and ContainsData 2016-05-16 16:45:00 +09:30
White
275ca6f9d1 Added a ConcurrentDictionary for plugin data to TSPlayer 2016-05-16 15:30:56 +09:30
Enerdy
7f9865bf5b TempGroups now override the group's permissions again instead of simply extending them 2016-01-13 17:17:04 +00:00
Enerdy
81fff9bd66 Pass down the permission being checked to the EventArgs (thanks @white) 2016-01-11 22:34:22 +00:00