Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Fixed an issue causing a null reference exception.
Browse files Browse the repository at this point in the history
Logging improvements in concealment.
  • Loading branch information
dodexahedron committed Apr 8, 2015
1 parent b4e4075 commit 42aefe3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
6 changes: 3 additions & 3 deletions EssentialsPlugin/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//2381
//2386
//
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyFileVersion("1.11.0.2381")]
[assembly: AssemblyVersion("1.11.0.2381")]
[assembly: AssemblyFileVersion("1.11.1.2386")]
[assembly: AssemblyVersion("1.11.1.2386")]
4 changes: 2 additions & 2 deletions EssentialsPlugin/AssemblyFileVersion.tt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@

using System.Reflection;

[assembly: AssemblyFileVersion("1.11.0.<#= revisionNumber #>")]
[assembly: AssemblyVersion("1.11.0.<#= revisionNumber #>")]
[assembly: AssemblyFileVersion("1.11.1.<#= revisionNumber #>")]
[assembly: AssemblyVersion("1.11.1.<#= revisionNumber #>")]
12 changes: 6 additions & 6 deletions EssentialsPlugin/EntityManagers/EntityManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public static void CheckAndConcealEntities()
}
catch(Exception ex)
{
Essentials.Log.Info(string.Format("Error getting players list. Check and Conceal failed: {0}", ex.ToString()));
Essentials.Log.Error( "Error getting players list. Check and Conceal failed: {0}", ex );
return;
}

try
{
MyAPIGateway.Entities.GetEntities(entities);
MyAPIGateway.Entities.GetEntities( entities );
}
catch
catch ( Exception ex )
{
Essentials.Log.Info("CheckAndConcealEntities(): Error getting entity list, skipping check");
Essentials.Log.Error( "Error getting entity list, skipping check", ex );
return;
}

Expand Down Expand Up @@ -162,12 +162,12 @@ public static void CheckAndConcealEntities()
co += (DateTime.Now - coStart).TotalMilliseconds;

if ((DateTime.Now - start).TotalMilliseconds > 2000)
Essentials.Log.Info(string.Format("Completed Conceal Check: {0}ms (gg: {3}, dc: {2} ms, br: {1}ms, co: {4}ms)", (DateTime.Now - start).TotalMilliseconds, blockRules, distCheck, getGrids, co));
Essentials.Log.Info( "Completed Conceal Check: {0}ms (gg: {3}, dc: {2} ms, br: {1}ms, co: {4}ms)", (DateTime.Now - start).TotalMilliseconds, blockRules, distCheck, getGrids, co );

}
catch (Exception ex)
{
Essentials.Log.Info(string.Format("CheckAndConceal(): {0}", ex.ToString()));
Essentials.Log.Error( ex );
}
finally
{
Expand Down
19 changes: 16 additions & 3 deletions EssentialsPlugin/ProcessHandlers/ProcessBlockEnforcement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,30 @@ private void ScanForBlockItems( )
if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.Off )
continue;

if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.BlockTypeId && string.IsNullOrEmpty( item.BlockTypeId ) )
{
Log.Warn( "Block Enforcement item for \"{0}\" is set to mode BlockTypeId but does not have BlockTypeId set." );
continue;
}
if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.BlockSubtypeId && string.IsNullOrEmpty( item.BlockSubtypeId ) )
{
Log.Warn( "Block Enforcement item for \"{0}\" is set to mode BlockSubtypeId but does not have BlockSubtypeId set." );
continue;
}

if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.BlockSubtypeId
&& !string.IsNullOrEmpty( block.BlockDefinition.SubtypeId )
&& block.BlockDefinition.SubtypeId.Contains( item.BlockTypeId ) )
&& block.BlockDefinition.SubtypeId.Contains( item.BlockSubtypeId ) )
{
if ( blocks.ContainsKey( item ) )
blocks[ item ] += 1;
else
blocks.Add( item, 1 );
}

if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.BlockId && block.BlockDefinition.TypeIdString.Contains( item.BlockTypeId ) )
if ( item.Mode == SettingsBlockEnforcementItem.EnforcementMode.BlockTypeId
&& !string.IsNullOrEmpty( block.BlockDefinition.TypeIdString )
&& block.BlockDefinition.TypeIdString.Contains( item.BlockTypeId ) )
{
if ( blocks.ContainsKey( item ) )
blocks[ item ] += 1;
Expand Down Expand Up @@ -163,7 +176,7 @@ private void DeleteReverse( SettingsBlockEnforcementItem blockEnforcementSetting
count++;
}
break;
case SettingsBlockEnforcementItem.EnforcementMode.BlockId:
case SettingsBlockEnforcementItem.EnforcementMode.BlockTypeId:
if ( block.BlockDefinition.TypeIdString.Contains( blockEnforcementSetting.BlockTypeId ) )
{
blocksToRemove.Add( block );
Expand Down
4 changes: 1 addition & 3 deletions EssentialsPlugin/Settings/SettingsBlockEnforcementItem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
namespace EssentialsPlugin.Settings
{
using System;

public class SettingsBlockEnforcementItem
{
public enum EnforcementMode
{
Off = 0,
BlockId = 1,
BlockTypeId = 1,
BlockSubtypeId = 2
}

Expand Down

0 comments on commit 42aefe3

Please sign in to comment.