This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
4,714 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.30723.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EssentialsPlugin", "EssentialsPlugin\EssentialsPlugin.csproj", "{2F02801E-F501-4DF7-BBBF-212A65026680}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2F02801E-F501-4DF7-BBBF-212A65026680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2F02801E-F501-4DF7-BBBF-212A65026680}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2F02801E-F501-4DF7-BBBF-212A65026680}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2F02801E-F501-4DF7-BBBF-212A65026680}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//321 | ||
// | ||
// 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.0.1.321")] | ||
[assembly: AssemblyVersion("1.0.1.321")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<#@ template language="C#" hostSpecific="True"#> | ||
<#@ output extension="cs" #> | ||
<#@ import namespace="System.IO" #> | ||
<# | ||
int revisionNumber; | ||
try | ||
{ | ||
//If we cannot find the file, the revision number is set to zero, | ||
//so even if the file doesn't exists the generation will run anyway. | ||
//NOTE: we suppose we're not messing with the generated file | ||
using(var f = File.OpenText(Host.ResolvePath("AssemblyFileVersion.cs"))) | ||
{ | ||
//We're reading the previous revision number; in order to make the | ||
//code as simple as we can, we're just going to rewrite it on the first row, commented. | ||
//This is not elegant, but it's simple enough and quite effective. | ||
string s = f.ReadLine().Replace("//",""); | ||
revisionNumber = int.Parse(s) + 1; | ||
} | ||
}catch | ||
{ | ||
revisionNumber = 0; | ||
} | ||
#> | ||
//<#=revisionNumber#> | ||
// | ||
// 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.0.1.<#= revisionNumber #>")] | ||
[assembly: AssemblyVersion("1.0.1.<#= revisionNumber #>")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Linq; | ||
using SEModAPIInternal.API.Common; | ||
using EssentialsPlugin.Utility; | ||
|
||
namespace EssentialsPlugin.ChatHandlers | ||
{ | ||
public abstract class ChatHandlerBase | ||
{ | ||
public ChatHandlerBase() | ||
{ | ||
Logging.WriteLineAndConsole(string.Format("Added chat handler: {0}", GetCommandText())); | ||
} | ||
|
||
public virtual Boolean CanHandle(ulong steamId, String[] words, ref int commandCount) | ||
{ | ||
if (IsAdminCommand()) | ||
{ | ||
if (!PlayerManager.Instance.IsUserAdmin(steamId) && steamId != 0) | ||
return false; | ||
} | ||
|
||
commandCount = GetCommandText().Split(new char[] { ' ' }).Count(); | ||
if (words.Length > commandCount - 1) | ||
return String.Join(" ", words).ToLower().StartsWith(GetCommandText()); | ||
|
||
return false; | ||
} | ||
|
||
public abstract string GetHelp(); | ||
|
||
public virtual String GetCommandText() | ||
{ | ||
return ""; | ||
} | ||
|
||
public virtual bool IsAdminCommand() | ||
{ | ||
return false; | ||
} | ||
|
||
public virtual bool AllowedInConsole() | ||
{ | ||
return false; | ||
} | ||
|
||
public virtual bool HandleCommand(ulong userId, String[] words) | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
EssentialsPlugin/ChatHandlers/HandleAdminDeleteGridsArea.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
using EssentialsPlugin.Utility; | ||
|
||
using Sandbox.ModAPI; | ||
using Sandbox.Common.ObjectBuilders; | ||
|
||
using VRageMath; | ||
|
||
using SEModAPIInternal.API.Entity; | ||
using SEModAPIInternal.API.Entity.Sector.SectorObject; | ||
|
||
namespace EssentialsPlugin.ChatHandlers | ||
{ | ||
public class HandleAdminDeleteGridsArea : ChatHandlerBase | ||
{ | ||
public override string GetHelp() | ||
{ | ||
return "This command allows you to delete all grids from an area defined by x, y, z, and radius. Usage: /admin delete grids area [X] [Y] [Z] [RADIUS]"; | ||
} | ||
|
||
public override string GetCommandText() | ||
{ | ||
return "/admin delete grids area"; | ||
} | ||
|
||
public override bool IsAdminCommand() | ||
{ | ||
return true; | ||
} | ||
|
||
public override bool AllowedInConsole() | ||
{ | ||
return true; | ||
} | ||
|
||
// admin deletearea x y z radius | ||
public override bool HandleCommand(ulong userId, string[] words) | ||
{ | ||
if (words.Count() != 4 && words.Count() != 0) | ||
return false; | ||
|
||
if (words.Count() != 4) | ||
{ | ||
Communication.SendPrivateInformation(userId, GetHelp()); | ||
return true; | ||
} | ||
|
||
// Test Input | ||
float test = 0; | ||
for(int r = 0; r < 4; r++) | ||
{ | ||
if(!float.TryParse(words[r], out test)) | ||
{ | ||
Communication.SendPrivateInformation(userId, string.Format("The value at position {0} - '{1}' is invalid. Please try the command again.", r + 1, words[r])); | ||
return true; | ||
} | ||
} | ||
|
||
Vector3D startPosition = new Vector3(float.Parse(words[0]), float.Parse(words[1]), float.Parse(words[2])); | ||
float radius = float.Parse(words[3]); | ||
CubeGrids.RemoveGridsInSphere(userId, startPosition, radius, RemoveGridTypes.All); | ||
return true; | ||
} | ||
|
||
} | ||
} |
144 changes: 144 additions & 0 deletions
144
EssentialsPlugin/ChatHandlers/HandleAdminDeleteNoBeacon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
using EssentialsPlugin.Utility; | ||
|
||
using Sandbox.ModAPI; | ||
using Sandbox.Common.ObjectBuilders; | ||
|
||
using VRageMath; | ||
|
||
using SEModAPIInternal.API.Entity; | ||
using SEModAPIInternal.API.Entity.Sector.SectorObject; | ||
|
||
namespace EssentialsPlugin.ChatHandlers | ||
{ | ||
public class HandleAdminDeleteStationsArea : ChatHandlerBase | ||
{ | ||
public override string GetHelp() | ||
{ | ||
return "This command allows you to delete all stations from an area defined by x, y, z, and radius. Usage: /admin delete ships area [X] [Y] [Z] [RADIUS]"; | ||
} | ||
|
||
public override string GetCommandText() | ||
{ | ||
return "/admin delete stations area"; | ||
} | ||
|
||
public override bool IsAdminCommand() | ||
{ | ||
return true; | ||
} | ||
|
||
public override bool AllowedInConsole() | ||
{ | ||
return true; | ||
} | ||
|
||
// admin deletearea x y z radius | ||
public override bool HandleCommand(ulong userId, string[] words) | ||
{ | ||
HashSet<IMyEntity> entities = new HashSet<IMyEntity>(); | ||
HashSet<IMyEntity> entitiesToConfirm = new HashSet<IMyEntity>(); | ||
HashSet<IMyEntity> entitiesConnected = new HashSet<IMyEntity>(); | ||
List<IMyEntity> entitiesFound = new List<IMyEntity>(); | ||
Wrapper.GameAction(() => | ||
{ | ||
MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid); | ||
|
||
foreach (IMyEntity entity in entities) | ||
{ | ||
if (!(entity is IMyCubeGrid)) | ||
continue; | ||
|
||
IMyCubeGrid grid = (IMyCubeGrid)entity; | ||
List<IMySlimBlock> blocks = new List<IMySlimBlock>(); | ||
grid.GetBlocks(blocks, x => x.FatBlock != null && x.FatBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Beacon)); | ||
|
||
if (blocks.Count > 0) | ||
continue; | ||
|
||
entitiesToConfirm.Add(grid); | ||
} | ||
|
||
foreach (IMyEntity entity in entitiesToConfirm) | ||
{ | ||
IMyCubeGrid grid = (IMyCubeGrid)entity; | ||
List<IMySlimBlock> blocks = new List<IMySlimBlock>(); | ||
grid.GetBlocks(blocks, x => x.FatBlock != null); | ||
foreach (IMySlimBlock block in blocks) | ||
{ | ||
if (block.FatBlock != null) | ||
{ | ||
IMyCubeBlock cubeBlock = block.FatBlock; | ||
|
||
if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_ShipConnector)) | ||
{ | ||
MyObjectBuilder_ShipConnector connector = (MyObjectBuilder_ShipConnector)cubeBlock.GetObjectBuilderCubeBlock(); | ||
if (connector.Connected) | ||
{ | ||
IMyEntity connectedEntity = (IMyEntity)MyAPIGateway.Entities.GetEntityById(connector.ConnectedEntityId); | ||
|
||
if (connectedEntity != null) | ||
entitiesConnected.Add(entity); | ||
|
||
break; | ||
} | ||
} | ||
|
||
if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_PistonBase)) | ||
{ | ||
MyObjectBuilder_PistonBase pistonBase = (MyObjectBuilder_PistonBase)cubeBlock.GetObjectBuilderCubeBlock(); | ||
if (pistonBase.TopBlockId != 0) | ||
{ | ||
IMyEntity connectedEntity = (IMyEntity)MyAPIGateway.Entities.GetEntityById(pistonBase.TopBlockId); | ||
|
||
if (connectedEntity != null) | ||
entitiesConnected.Add(entity); | ||
|
||
break; | ||
} | ||
} | ||
|
||
if (cubeBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_MotorAdvancedStator)) | ||
{ | ||
MyObjectBuilder_MotorAdvancedStator stator = (MyObjectBuilder_MotorAdvancedStator)cubeBlock.GetObjectBuilderCubeBlock(); | ||
if (stator.RotorEntityId != 0) | ||
{ | ||
IMyEntity connectedEntity = (IMyEntity)MyAPIGateway.Entities.GetEntityById(stator.RotorEntityId); | ||
|
||
if (connectedEntity != null) | ||
entitiesConnected.Add(entity); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!entitiesConnected.Contains(entity)) | ||
entitiesFound.Add(entity); | ||
} | ||
|
||
foreach (IMyEntity entity in entitiesFound) | ||
{ | ||
Communication.SendPrivateInformation(userId, string.Format("Found entity '{0}' at {1} with no beacon.", entity.EntityId, General.Vector3DToString(entity.GetPosition()))); | ||
} | ||
|
||
for(int r = entitiesFound.Count - 1; r >= 0; r--) | ||
{ | ||
IMyEntity entity = entitiesFound[r]; | ||
MyAPIGateway.Entities.RemoveEntity(entity); | ||
} | ||
}); | ||
|
||
Communication.SendPrivateInformation(userId, string.Format("Removed {0} grids with no beacons", entitiesFound.Count)); | ||
|
||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.