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

Commit 1cbb5ef

Browse files
committed
Change block enforcement to notify SmallOwners. Added message segmenter to account for data messages > 4KB. Fixed exceptions in concealment. Implemented per-player block enforcement.
1 parent 67c97b9 commit 1cbb5ef

File tree

12 files changed

+767
-139
lines changed

12 files changed

+767
-139
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//197
1+
//264
22
//
33
// This code was generated by a tool. Any changes made manually will be lost
44
// the next time this code is regenerated.
55
//
66

77
using System.Reflection;
88

9-
[assembly: AssemblyFileVersion("1.13.6.197")]
10-
[assembly: AssemblyVersion("1.13.6.197")]
9+
[assembly: AssemblyFileVersion("1.13.6.264")]
10+
[assembly: AssemblyVersion("1.13.6.264")]

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminConceal.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,21 @@ public override bool HandleCommand(ulong userId, string[] words)
7878

7979
Communication.SendPrivateInformation(userId, "==== Concealed Entities ===");
8080
int count = 0;
81-
foreach (IMyEntity entity in entities)
81+
foreach (MyEntity entity in EntityManagement.UnregisteredEntities)
8282
{
83-
if (!(entity is IMyCubeGrid))
84-
continue;
85-
86-
if (entity.InScene)
83+
if (!(entity is MyCubeGrid))
8784
continue;
88-
89-
IMyCubeGrid grid = (IMyCubeGrid)entity;
85+
86+
MyCubeGrid grid = (MyCubeGrid)entity;
9087
long ownerId = 0;
9188
string ownerName = "";
9289
if (grid.BigOwners.Count > 0)
9390
{
9491
ownerId = grid.BigOwners.First();
95-
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name;
92+
ownerName = PlayerMap.Instance.GetPlayerNameFromPlayerId( ownerId );
9693
}
97-
98-
if (ownerName == "")
99-
ownerName = "No one";
100-
101-
Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.GetPosition())));
94+
95+
Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.PositionComp.GetPosition())));
10296
count++;
10397
}
10498

EssentialsPlugin/ChatHandlers/ChatHandlerBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
using NLog;
66
using Sandbox.Engine.Multiplayer;
77
using Sandbox.Game.World;
8+
using SEModAPI.API;
89
using SEModAPIInternal.API.Common;
910
using Utility;
1011
public abstract class ChatHandlerBase
1112
{
1213
protected static readonly Logger Log = LogManager.GetLogger( "PluginLog" );
1314
public ChatHandlerBase( )
1415
{
15-
Log.Debug(string.Format("Added chat handler: {0}", GetCommandText()));
16+
if ( ExtenderOptions.IsDebugging )
17+
Log.Debug( $"Added chat handler: {GetCommandText()}" );
1618
}
1719

1820
public virtual Boolean CanHandle(ulong steamId, String[] words, ref int commandCount)

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ private static void ConcealEntity( MyEntity entity )
249249
try
250250
{
251251
pos = 1;
252-
long ownerId = ((MyCubeGrid)entity).BigOwners.FirstOrDefault();
252+
long ownerId = 0;
253+
if ( ( (MyCubeGrid)entity ).BigOwners.Count > 0 )
254+
ownerId = ( (MyCubeGrid)entity ).BigOwners[0];
255+
253256
string ownerName = PlayerMap.Instance.GetPlayerNameFromPlayerId( ownerId );
254257

255258
if ( PluginSettings.Instance.DynamicShowMessages )

EssentialsPlugin/Essentials.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,14 +959,43 @@ public bool BlockEnforcementEnabled
959959
}
960960

961961
[Category( "Block Enforcement System" )]
962-
[Description( "Enforcement Items. These are how block enforcements are defined. Each item is a block that is scanned for." )]
962+
[Description( "Enforcement Items. These are how block enforcements are defined. Each item is a block that is scanned for." )]
963963
[Browsable( true )]
964964
[ReadOnly( false )]
965965
public MTObservableCollection<SettingsBlockEnforcementItem> BlockEnforcementItems
966966
{
967967
get { return PluginSettings.Instance.BlockEnforcementItems; }
968968
}
969969

970+
[Category("Block Enforcement System")]
971+
[Description("This functions like the normal block enforcement, except blocks are counted per player instead of per grid.")]
972+
[Browsable(true)]
973+
[ReadOnly(false)]
974+
public bool PlayerBlockEnforcementEnabled
975+
{
976+
get { return PluginSettings.Instance.PlayerBlockEnforcementEnabled; }
977+
set { PluginSettings.Instance.PlayerBlockEnforcementEnabled = value; }
978+
}
979+
980+
[Category("Block Enforcement System")]
981+
[Description("If a block in player enforcement is created with no owner, it will be changed to the nearest player or the owner of the grid if there are no players.")]
982+
[Browsable(true)]
983+
[ReadOnly(false)]
984+
public bool PlayerBlockEnforcementChangeOwner
985+
{
986+
get { return PluginSettings.Instance.PlayerBlockEnforcementChangeOwner; }
987+
set { PluginSettings.Instance.PlayerBlockEnforcementChangeOwner = value; }
988+
}
989+
990+
[Category("Block Enforcement System")]
991+
[Description("Enforcement Items. These are how block enforcements are defined. Each item is a block that is scanned for.")]
992+
[Browsable(true)]
993+
[ReadOnly(false)]
994+
public MTObservableCollection<SettingsBlockEnforcementItem> PlayerBlockEnforcementItems
995+
{
996+
get { return PluginSettings.Instance.PlayerBlockEnforcementItems; }
997+
}
998+
970999
[Category( "Reserved Slots" )]
9711000
[Description( "This reserves slots for whitelisted players or groups." )]
9721001
[Browsable( true )]
@@ -1294,8 +1323,10 @@ private void DoInit( string path )
12941323

12951324
Protection.Init( );
12961325
ProcessReservedSlots.Init( );
1326+
PlayerBlockEnforcement.Init();
12971327

1298-
//MyAPIGateway.Multiplayer.RegisterMessageHandler(9005, Communication.ReveiveMessageParts);
1328+
MyAPIGateway.Multiplayer.RegisterMessageHandler(9005, Communication.ReceiveMessageParts);
1329+
MyAPIGateway.Multiplayer.RegisterMessageHandler( 9007, Communication.HandleAddConcealExempt );
12991330
Log.Info( "Plugin '{0}' initialized. (Version: {1} ID: {2})", Name, Version, Id );
13001331
}
13011332

@@ -1425,6 +1456,8 @@ public void Shutdown( )
14251456
thread.Abort( );
14261457

14271458
_processThread.Abort( );
1459+
MyAPIGateway.Multiplayer.UnregisterMessageHandler(9005, Communication.ReceiveMessageParts);
1460+
MyAPIGateway.Multiplayer.UnregisterMessageHandler( 9007, Communication.HandleAddConcealExempt );
14281461
}
14291462

14301463
public void Update( )

EssentialsPlugin/EssentialsPlugin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@
201201
<Compile Include="Utility\DockingItem.cs" />
202202
<Compile Include="Utility\Extensions.cs" />
203203
<Compile Include="Utility\GridGroup.cs" />
204+
<Compile Include="Utility\PlayerBlockEnforcement.cs" />
204205
<Compile Include="Utility\Protection.cs" />
205206
<Compile Include="Utility\TimedEntityCleanup.cs" />
206207
<Compile Include="Utility\Communication.cs" />
207208
<Compile Include="Utility\CubeGrid.cs" />
208209
<Compile Include="Utility\DockingZone.cs" />
209210
<Compile Include="Utility\Entity.cs" />
210211
<Compile Include="EntityManagers\EntityManagement.cs" />
211-
<Compile Include="Utility\Faction.cs" />
212212
<Compile Include="Utility\MathUtility.cs" />
213213
<Compile Include="Utility\Player.cs" />
214214
<Compile Include="Utility\Utility.cs" />

EssentialsPlugin/ProcessHandlers/ProcessBlockEnforcement.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using EssentialsPlugin.Settings;
77
using EssentialsPlugin.Utility;
8+
using Sandbox.Game.World;
89
using Sandbox.ModAPI;
910
using Sandbox.ModAPI.Ingame;
1011
using SEModAPIInternal.API.Common;
@@ -172,7 +173,7 @@ private void ScanForBlockItems( )
172173
}
173174
if ( !foundAdmin )
174175
{
175-
foreach ( long playerId in grid.BigOwners )
176+
foreach ( long playerId in grid.SmallOwners )
176177
{
177178
ulong steamId = PlayerMap.Instance.GetSteamIdFromPlayerId( playerId );
178179
if ( steamId > 0 )

EssentialsPlugin/Settings/PluginSettings.cs

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public class PluginSettings
106106
private bool _blockEnforcementEnabled;
107107
private MTObservableCollection<SettingsBlockEnforcementItem> _blockEnforcementItems;
108108

109+
private bool _playerBlockEnforcementEnabled;
110+
private MTObservableCollection<SettingsBlockEnforcementItem> _playerBlockEnforcementItems;
111+
private bool _changeBlockOwnerNearest;
112+
109113
private bool _gameModeConquestEnabled;
110114

111115
private bool _reservedSlotsEnabled;
@@ -115,7 +119,7 @@ public class PluginSettings
115119
private bool _reservedSlotsAdmins;
116120

117121
private bool _timedCommandsEnabled;
118-
private MTObservableCollection<TimedCommandItem> _TimedCommandsItem;
122+
private MTObservableCollection<TimedCommandItem> _timedCommandsItem;
119123

120124
private bool _atmosphericCargoShipsEnabled;
121125
private float _atmosphericCargoShipSpawnTime;
@@ -830,9 +834,39 @@ public MTObservableCollection<SettingsBlockEnforcementItem> BlockEnforcementItem
830834
_blockEnforcementItems = value;
831835
Save();
832836
}
833-
}
837+
}
834838

835-
public bool GameModeConquestEnabled
839+
public bool PlayerBlockEnforcementEnabled
840+
{
841+
get { return _playerBlockEnforcementEnabled; }
842+
set
843+
{
844+
_playerBlockEnforcementEnabled = value;
845+
Save();
846+
}
847+
}
848+
849+
public bool PlayerBlockEnforcementChangeOwner
850+
{
851+
get { return _changeBlockOwnerNearest; }
852+
set
853+
{
854+
_changeBlockOwnerNearest = value;
855+
Save();
856+
}
857+
}
858+
859+
public MTObservableCollection<SettingsBlockEnforcementItem> PlayerBlockEnforcementItems
860+
{
861+
get { return _playerBlockEnforcementItems; }
862+
set
863+
{
864+
_playerBlockEnforcementItems = value;
865+
Save();
866+
}
867+
}
868+
869+
public bool GameModeConquestEnabled
836870
{
837871
get { return _gameModeConquestEnabled; }
838872
set
@@ -925,10 +959,10 @@ public bool TimedCommandsEnabled
925959

926960
public MTObservableCollection<TimedCommandItem> TimedCommandsItems
927961
{
928-
get { return _TimedCommandsItem; }
962+
get { return _timedCommandsItem; }
929963
set
930964
{
931-
_TimedCommandsItem = value;
965+
_timedCommandsItem = value;
932966
Save( );
933967
}
934968
}
@@ -1033,9 +1067,12 @@ public PluginSettings()
10331067
_blockEnforcementItems = new MTObservableCollection<SettingsBlockEnforcementItem>();
10341068
_blockEnforcementItems.CollectionChanged += ItemsCollectionChanged;
10351069

1070+
_playerBlockEnforcementItems = new MTObservableCollection<SettingsBlockEnforcementItem>();
1071+
_playerBlockEnforcementItems.CollectionChanged += ItemsCollectionChanged;
1072+
10361073
_timedCommandsEnabled = false;
1037-
_TimedCommandsItem = new MTObservableCollection<TimedCommandItem>( );
1038-
_TimedCommandsItem.CollectionChanged += ItemsCollectionChanged;
1074+
_timedCommandsItem = new MTObservableCollection<TimedCommandItem>( );
1075+
_timedCommandsItem.CollectionChanged += ItemsCollectionChanged;
10391076

10401077
_atmosphericCargoShipsEnabled = false;
10411078
_atmosphericCargoShipSpawnTime = 10.0f;

0 commit comments

Comments
 (0)