Skip to content

Commit bc5234f

Browse files
committed
Updates
1 parent 21b4b00 commit bc5234f

5 files changed

Lines changed: 104 additions & 31 deletions

File tree

‎Essentials/Commands/VoxelModule.cs‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,32 @@ public void ResetVoxelArea(float Radius)
259259
}
260260

261261

262+
}
263+
264+
[Command("reset planet area", "Resets voxel damange in specified radius from player")]
265+
[Permission(MyPromoteLevel.Admin)]
266+
public void ResetPlanetVoxelArea(float Radius)
267+
{
268+
if (Context.Player == null)
269+
Context.Respond("Invalid command input! Must be ingame!");
270+
271+
272+
if(Radius <= 0)
273+
{
274+
Context.Respond("Inavlid radius!");
275+
return;
276+
}
277+
278+
279+
if(ResetPlanetVoxelsInArea(Context.Player.GetPosition(), Radius)) {
280+
Context.Respond("Voxel reset complete!");
281+
}
282+
else
283+
{
284+
Context.Respond("Couldnt reset voxels! Check log for more information!");
285+
}
286+
287+
262288
}
263289

264290
[Command("reset gps", "Resets voxel damange in specified radius from given point")]
@@ -342,6 +368,67 @@ private static bool ResetVoxelInArea(Vector3D Center, float Radius)
342368
return false;
343369
}
344370
}
371+
372+
private static bool ResetPlanetVoxelsInArea(Vector3D center, float radius)
373+
{
374+
try
375+
{
376+
BoundingSphereD sphere = new BoundingSphereD(center, radius);
377+
List<MyPlanet> planets = MyEntities.GetEntitiesInSphere(ref sphere).OfType<MyPlanet>().ToList();
378+
if (planets.Count == 0)
379+
return true;
380+
381+
foreach (var planet in planets)
382+
{
383+
using (planet.Pin())
384+
{
385+
if (planet.MarkedForClose)
386+
{
387+
continue;
388+
}
389+
390+
MyShapeSphere shape = new MyShapeSphere
391+
{
392+
Center = center,
393+
Radius = radius
394+
};
395+
396+
// Planet-specific adjustment to voxel coordinates
397+
Vector3I minCorner, maxCorner;
398+
BoundingBoxD shapeAabb = shape.GetWorldBoundaries();
399+
Vector3I storageSize = planet.Storage.Size;
400+
MyVoxelCoordSystems.WorldPositionToVoxelCoord(planet.PositionLeftBottomCorner, ref shapeAabb.Min, out minCorner);
401+
MyVoxelCoordSystems.WorldPositionToVoxelCoord(planet.PositionLeftBottomCorner, ref shapeAabb.Max, out maxCorner);
402+
minCorner += planet.StorageMin;
403+
maxCorner += planet.StorageMin;
404+
maxCorner += 1;
405+
storageSize -= 1;
406+
407+
Vector3I.Clamp(ref minCorner, ref Vector3I.Zero, ref storageSize, out minCorner);
408+
Vector3I.Clamp(ref maxCorner, ref Vector3I.Zero, ref storageSize, out maxCorner);
409+
410+
planet.Storage.DeleteRange(MyStorageDataTypeFlags.ContentAndMaterial, minCorner, maxCorner, false);
411+
412+
BoundingBoxD cutOutBox = shape.GetWorldBoundaries();
413+
MySandboxGame.Static.Invoke(delegate
414+
{
415+
if (planet.Storage != null)
416+
{
417+
planet.Storage.NotifyChanged(minCorner, maxCorner, MyStorageDataTypeFlags.ContentAndMaterial);
418+
MyVoxelGenerator.NotifyVoxelChanged(MyVoxelBase.OperationType.Revert, planet, ref cutOutBox);
419+
}
420+
}, "ResetPlanetVoxels notify");
421+
}
422+
}
423+
return true;
424+
}
425+
catch (Exception ex)
426+
{
427+
_log.Error(ex, "Planet voxel reset failed!");
428+
return false;
429+
}
430+
}
431+
345432

346433
private static LockToken PinDelete()
347434
{

��Essentials/Conditions/ConditionsImplementations.cs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Text.RegularExpressions;
8+
using Sandbox.ModAPI;
89
using Vector3D = VRageMath.Vector3D;
910

1011
namespace Essentials.Commands
@@ -61,6 +62,21 @@ public static bool HasGridType(MyCubeGrid grid, string gridType)
6162
// In all other cases, just return false.
6263
return false;
6364
}
65+
66+
public static bool IsNPCTradeStation(MyCubeGrid grid)
67+
{
68+
if (grid == null)
69+
return false;
70+
71+
if (grid.IsStatic && grid.GridSizeEnum == VRage.Game.MyCubeSize.Large)
72+
{
73+
var faction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(grid.BigOwners.FirstOrDefault());
74+
if (faction != null && faction.Tag == "NPC")
75+
return true;
76+
}
77+
78+
return false;
79+
}
6480

6581
[Condition("hasownertype", helpText: "Finds grids with the specified owner type (npc | player | nobody).")]
6682
public static bool HasOwnerType(MyCubeGrid grid, string ownerType)

‎Essentials/EssentialsPlugin.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ private void EntityAdded(MyEntity myEntity)
215215

216216

217217
public static void InsertDiscordID(ulong steamID, string discordID, string discordName, Dictionary<ulong,string> RoleData) {
218-
PlayerAccountModule.InsertDiscord(steamID, discordID, discordName, RoleData);
219-
218+
//removed for now
220219
}
221220

222221
private void ProcessBags()

‎Essentials/Patches/ChatMessagePatch.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ private static bool OnChatMessageReceived_Server(ref ChatMsg msg) {
5151
var Account = PlayerAccountData.GetAccount(msg.Author);
5252
if (Account != null) {
5353
var Rank = RanksAndPermissions.GetRankData(Account.Rank);
54-
if (Rank.DisplayPrefix) {
55-
msg.Author = 0;
56-
msg.CustomAuthorName = $"{Rank.Prefix}{Account.Player}";
57-
}
5854
}
5955
return true;
6056
}

‎Essentials/PlayerAccountModule.cs‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,6 @@ public void SaveAccountData() {
118118
File.WriteAllText(EssentialsPlugin.Instance.homeDataPath, JsonConvert.SerializeObject(PlayersAccounts, Formatting.Indented));
119119
}
120120

121-
public static void InsertDiscord(ulong steamID, string discordID, string discordName, Dictionary<ulong, string> RoleData) {
122-
Log.Info($"DiscordID for {steamID} received from SEDB!... Inserting into player account ({discordID})");
123-
var AccModule = new PlayerAccountModule();
124-
var account = AccModule.GetAccount(steamID);
125-
126-
account.DiscordData.DiscordID = ulong.Parse(discordID);
127-
account.DiscordData.DiscordName = discordName;
128-
foreach (var role in RoleData) {
129-
if (account.DiscordData.DiscordID == ulong.Parse(discordID)) {
130-
account.DiscordData.DiscordName = discordName;
131-
if (!account.DiscordData.Roles.ContainsKey(role.Key)) {
132-
account.DiscordData.Roles.Add(role.Key, role.Value);
133-
}
134-
}
135-
}
136-
137-
AccModule.UpdatePlayerAccount(account);
138-
}
139-
140121
public void GenerateAccount(Torch.API.IPlayer player) {
141122
try {
142123
var state = new MyP2PSessionState();
@@ -183,12 +164,6 @@ public void CheckIp(Torch.API.IPlayer Player) {
183164
Sandbox.Engine.Networking.MyGameService.Peer2Peer.GetSessionState(Player.SteamId, ref state);
184165
var ip = new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray());
185166

186-
foreach (var account in PlayersAccounts) {
187-
if (account.KnownIps.Contains(ip.ToString()) && account.Player != Player.Name) {
188-
Log.Warn($"WARNING! {Player.Name} shares the same IP address as {account.Player}");
189-
}
190-
}
191-
192167
}
193168

194169
public string GetRank(ulong steamID) {

0 commit comments

Comments
 (0)