This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use colored chat for server messages. Add logging to planet reset. Ad…
…d /admin static command
- Loading branch information
Showing
6 changed files
with
190 additions
and
89 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
//392 | ||
//398 | ||
// | ||
// 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.13.7.392")] | ||
[assembly: AssemblyVersion("1.13.7.392")] | ||
[assembly: AssemblyFileVersion("1.13.7.398")] | ||
[assembly: AssemblyVersion("1.13.7.398")] |
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
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,98 @@ | ||
namespace EssentialsPlugin.ChatHandlers.Admin | ||
{ | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using ParallelTasks; | ||
using Sandbox.Definitions; | ||
using Sandbox.Engine.Multiplayer; | ||
using Sandbox.Engine.Voxels; | ||
using Sandbox.Game.Entities; | ||
using Sandbox.Game.Entities.Character; | ||
using Sandbox.Game.Replication; | ||
using Utility; | ||
using VRage.Game; | ||
|
||
public class HandleAdminStatic : ChatHandlerBase | ||
{ | ||
|
||
public override string GetHelp() | ||
{ | ||
return "Sets grids as static. Usage: /admin static (all, small, large)"; | ||
} | ||
|
||
public override string GetCommandText() | ||
{ | ||
return "/admin static"; | ||
} | ||
|
||
public override bool IsAdminCommand() | ||
{ | ||
return true; | ||
} | ||
|
||
public override bool AllowedInConsole() | ||
{ | ||
return true; | ||
} | ||
|
||
public override bool HandleCommand( ulong userId, string[ ] words ) | ||
{ | ||
if (words.Length != 1) | ||
{ | ||
Communication.SendPrivateInformation( userId, GetHelp( ) ); | ||
return false; | ||
} | ||
bool small; | ||
bool large; | ||
|
||
switch (words[0].ToLower( )) | ||
{ | ||
case "small": | ||
small = true; | ||
large = false; | ||
break; | ||
case "large": | ||
small = false; | ||
large = true; | ||
break; | ||
case "all": | ||
small = true; | ||
large = true; | ||
break; | ||
default: | ||
Communication.SendPrivateInformation( userId, GetHelp( ) ); | ||
return false; | ||
} | ||
|
||
var ents = MyEntities.GetEntities( ).ToArray( ); | ||
int count = 0; | ||
foreach (var ent in ents) | ||
{ | ||
var grid = ent as MyCubeGrid; | ||
if (grid == null) | ||
continue; | ||
|
||
if (grid.Physics == null || grid.IsStatic) | ||
continue; | ||
|
||
if (grid.GridSizeEnum == MyCubeSize.Large && large) | ||
{ | ||
grid.RequestConversionToStation( ); | ||
Essentials.Log.Info( $"Converted {grid.DisplayName} to static" ); | ||
count++; | ||
} | ||
else if (grid.GridSizeEnum == MyCubeSize.Small && small) | ||
{ | ||
grid.RequestConversionToStation( ); | ||
Essentials.Log.Info( $"Converted {grid.DisplayName} to static" ); | ||
count++; | ||
} | ||
} | ||
Communication.SendPrivateInformation( userId, $"Converted {count} grids to static" ); | ||
return true; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
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
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
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