11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using System . Text ;
54using System . Threading . Tasks ;
5+ using System . Threading ;
6+ using Sandbox . Game . Entities ;
7+ using Sandbox . Game . Entities . Cube ;
8+ using Sandbox . Game . World ;
9+ using Sandbox . ModAPI ;
10+ using EssentialsPlugin . Settings ;
11+ using SEModAPIInternal . API . Common ;
12+ using VRage . Game ;
13+ using VRage . Game . Entity ;
14+ using VRageMath ;
615
716namespace EssentialsPlugin . Utility
817{
9- using System . Net ;
10- using System . Threading ;
11- using Sandbox . Definitions ;
12- using Sandbox . Game . Entities ;
13- using Sandbox . Game . Entities . Cube ;
14- using Sandbox . Game . World ;
15- using Settings ;
16- using SEModAPIInternal . API . Common ;
17- using VRage . Game ;
18- using VRage . Game . Entity ;
19- using VRage . Game . ModAPI ;
20- using VRageMath ;
21-
2218 public static class PlayerBlockEnforcement
2319 {
2420 private static bool _init ;
@@ -85,7 +81,7 @@ private static void InitGrid( MyCubeGrid grid )
8581 if ( fatBlock . OwnerId == 0 )
8682 {
8783 if ( fatBlock . CubeGrid . BigOwners . Count > 0 && PluginSettings . Instance . PlayerBlockEnforcementChangeOwner )
88- Wrapper . GameAction ( ( ) => fatBlock . ChangeBlockOwnerRequest ( fatBlock . CubeGrid . BigOwners . First ( ) , MyOwnershipShareModeEnum . Faction ) ) ;
84+ MyAPIGateway . Utilities . InvokeOnGameThread ( ( ) => fatBlock . ChangeBlockOwnerRequest ( fatBlock . CubeGrid . BigOwners . First ( ) , MyOwnershipShareModeEnum . Faction ) ) ;
8985 else if ( PluginSettings . Instance . PlayerBlockEnforcementChangeOwner )
9086 ChangeOwnershipToNearestPlayer ( fatBlock ) ;
9187 }
@@ -111,7 +107,7 @@ private static void InitGrid( MyCubeGrid grid )
111107 if ( fatBlock . OwnerId == 0 )
112108 {
113109 if ( fatBlock . CubeGrid . BigOwners . Count > 0 && PluginSettings . Instance . PlayerBlockEnforcementChangeOwner )
114- Wrapper . GameAction ( ( ) => fatBlock . ChangeBlockOwnerRequest ( fatBlock . CubeGrid . BigOwners . First ( ) , MyOwnershipShareModeEnum . Faction ) ) ;
110+ MyAPIGateway . Utilities . InvokeOnGameThread ( ( ) => fatBlock . ChangeBlockOwnerRequest ( fatBlock . CubeGrid . BigOwners . First ( ) , MyOwnershipShareModeEnum . Faction ) ) ;
115111 else if ( PluginSettings . Instance . PlayerBlockEnforcementChangeOwner )
116112 ChangeOwnershipToNearestPlayer ( fatBlock ) ;
117113 }
@@ -147,7 +143,7 @@ private static void ChangeOwnershipToNearestPlayer( MyTerminalBlock block )
147143
148144 if ( nearest == null )
149145 return ;
150- block . ChangeBlockOwnerRequest ( nearest . Identity . IdentityId , MyOwnershipShareModeEnum . Faction ) ;
146+ MyAPIGateway . Utilities . InvokeOnGameThread ( ( ) => block . ChangeBlockOwnerRequest ( nearest . Identity . IdentityId , MyOwnershipShareModeEnum . Faction ) ) ;
151147 } ) ;
152148 }
153149
@@ -443,12 +439,12 @@ private static void FatBlock_OwnershipChanged(MyTerminalBlock block)
443439 lock ( BlockOwners )
444440 {
445441 if ( BlockOwners . ContainsKey ( block ) )
446- Wrapper . GameAction ( ( ) => block . ChangeBlockOwnerRequest ( BlockOwners [ block ] , MyOwnershipShareModeEnum . Faction ) ) ;
442+ MyAPIGateway . Utilities . InvokeOnGameThread ( ( ) => block . ChangeBlockOwnerRequest ( BlockOwners [ block ] , MyOwnershipShareModeEnum . Faction ) ) ;
447443 else if ( PluginSettings . Instance . PlayerBlockEnforcementChangeOwner )
448444 {
449445 ChangeOwnershipToNearestPlayer ( block ) ;
450446 if ( block . OwnerId == 0 && block . CubeGrid . BigOwners . Count > 0 )
451- block . ChangeBlockOwnerRequest ( block . CubeGrid . BigOwners [ 0 ] , MyOwnershipShareModeEnum . Faction ) ;
447+ MyAPIGateway . Utilities . InvokeOnGameThread ( ( ) => block . ChangeBlockOwnerRequest ( block . CubeGrid . BigOwners [ 0 ] , MyOwnershipShareModeEnum . Faction ) ) ;
452448
453449 if ( block . OwnerId != 0 )
454450 BlockOwners [ block ] = block . OwnerId ;
0 commit comments