11using System ;
22using System . Collections . Generic ;
3- using System . Diagnostics . Contracts ;
43using System . Collections . ObjectModel ;
54using System . Linq ;
65using OTAPI . Tile ;
@@ -24,7 +23,7 @@ public class ProtectionManager {
2423 public Configuration Config {
2524 get { return this . config ; }
2625 set {
27- Contract . Requires < ArgumentNullException > ( value != null ) ;
26+ if ( value == null ) throw new ArgumentNullException ( ) ;
2827 this . config = value ;
2928 }
3029 }
@@ -248,9 +247,9 @@ public ProtectionEntry CreateProtection(
248247 TSPlayer player , DPoint tileLocation , bool checkIfBlockTypeProtectableByConfig = true ,
249248 bool checkTShockBuildAndRegionAccess = true , bool checkLimits = true
250249 ) {
251- Contract . Requires < ArgumentNullException > ( player != null ) ;
252- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] != null , "tileLocation" ) ;
253- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) , "tileLocation" ) ;
250+ if ( player == null ) throw new ArgumentNullException ( ) ;
251+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] != null ) ) throw new ArgumentException ( "tileLocation" ) ;
252+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) ) ) throw new ArgumentException ( "tileLocation" ) ;
254253
255254 ITile tile = TerrariaUtils . Tiles [ tileLocation ] ;
256255 int blockType = tile . type ;
@@ -288,7 +287,7 @@ public ProtectionEntry CreateProtection(
288287 }
289288
290289 public void RemoveProtection ( TSPlayer player , DPoint tileLocation , bool checkIfBlockTypeDeprotectableByConfig = true ) {
291- Contract . Requires < ArgumentNullException > ( player != null ) ;
290+ if ( player == null ) throw new ArgumentNullException ( ) ;
292291
293292 bool canDeprotectEverything = player . Group . HasPermission ( ProtectorPlugin . ProtectionMaster_Permission ) ;
294293 if ( TerrariaUtils . Tiles . IsValidCoord ( tileLocation ) ) {
@@ -321,9 +320,9 @@ public void RemoveProtection(TSPlayer player, DPoint tileLocation, bool checkIfB
321320 }
322321
323322 public void ProtectionShareAll ( TSPlayer player , DPoint tileLocation , bool shareOrUnshare , bool checkPermissions = false ) {
324- Contract . Requires < ArgumentNullException > ( player != null ) ;
325- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] != null , "tileLocation" ) ;
326- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) , "tileLocation" ) ;
323+ if ( player == null ) throw new ArgumentNullException ( ) ;
324+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] != null ) ) throw new ArgumentException ( "tileLocation" ) ;
325+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) ) ) throw new ArgumentException ( "tileLocation" ) ;
327326
328327 ProtectionEntry protection ;
329328 try {
@@ -346,9 +345,9 @@ public void ProtectionShareAll(TSPlayer player, DPoint tileLocation, bool shareO
346345 public void ProtectionShareUser (
347346 TSPlayer player , DPoint tileLocation , int targetUserId , bool shareOrUnshare = true , bool checkPermissions = false
348347 ) {
349- Contract . Requires < ArgumentNullException > ( player != null ) ;
350- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] != null , "tileLocation" ) ;
351- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) , "tileLocation" ) ;
348+ if ( player == null ) throw new ArgumentNullException ( ) ;
349+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] != null ) ) throw new ArgumentException ( "tileLocation" ) ;
350+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) ) ) throw new ArgumentException ( "tileLocation" ) ;
352351
353352 ProtectionEntry protection ;
354353 try {
@@ -383,10 +382,10 @@ public void ProtectionShareUser(
383382 public void ProtectionShareGroup (
384383 TSPlayer player , DPoint tileLocation , string targetGroupName , bool shareOrUnshare = true , bool checkPermissions = false
385384 ) {
386- Contract . Requires < ArgumentNullException > ( player != null ) ;
387- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] != null , "tileLocation" ) ;
388- Contract . Requires < ArgumentException > ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) , "tileLocation" ) ;
389- Contract . Requires < ArgumentNullException > ( targetGroupName != null ) ;
385+ if ( player == null ) throw new ArgumentNullException ( ) ;
386+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] != null ) ) throw new ArgumentException ( "tileLocation" ) ;
387+ if ( ! ( TerrariaUtils . Tiles [ tileLocation ] . active ( ) ) ) throw new ArgumentException ( "tileLocation" ) ;
388+ if ( targetGroupName == null ) throw new ArgumentNullException ( ) ;
390389
391390 ProtectionEntry protection ;
392391 try {
0 commit comments