From c1de974e16fc08d03482221798e584903304592f Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 17 Dec 2017 01:04:47 -0700 Subject: [PATCH] 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. --- TShockAPI/GetDataHandlers.cs | 2 +- TShockAPI/TSPlayer.cs | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index d21c0e36..959ec454 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2366,7 +2366,7 @@ namespace TShockAPI var type = Main.projectile[index].type; // TODO: This needs to be moved somewhere else. - if (args.Player.LacksProjectilePermission(index, type) && type != 102 && type != 100 && !TShock.Config.IgnoreProjKill) + if (!args.Player.HasProjectilePermission(index, type) && type != 102 && type != 100 && !TShock.Config.IgnoreProjKill) { args.Player.Disable("Does not have projectile permission to kill projectile.", DisableFlags.WriteToLogAndConsole); args.Player.RemoveProjectile(ident, owner); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index aae8ace8..868f20b2 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -804,15 +804,6 @@ namespace TShockAPI } } - /// Checks to see if this player object lacks access rights to a given projectile. Used by projectile bans. - /// The projectile index from Main.projectiles (NOT from a packet directly). - /// The type of projectile, from Main.projectiles. - /// If the player has lacks access rights to the projectile. - public bool LacksProjectilePermission(int index, int type) - { - return !HasProjectilePermission(index, type); - } - /// Checks to see if this player object has access rights to a given projectile. Used by projectile bans. /// The projectile index from Main.projectiles (NOT from a packet directly). /// The type of projectile, from Main.projectiles.