fix: Fixes missing methods. Adds more admin gump world building (#1675)

### Summary
- Fixe commands missing in helpinfo.
- Adds more admin gump world building options. 

### Screenshots

<img src="https://github.com/modernuo/ModernUO/assets/3953314/3001aa65-4f46-4ba4-89ed-745fefdd27c3" width="50%">
This commit is contained in:
Kamron Batman 2024-02-10 20:31:25 -08:00 • committed by GitHub
parent cf989151f1
commit 4479555156
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 212 additions and 201 deletions

View file

@ -6,20 +6,30 @@ namespace Server.Commands
{
public static class ExportCommand
{
private const string ExportFile = @"C:\Uo\WorldForge\items.wsc";
public static void Configure()
{
CommandSystem.Register("ExportWSC", AccessLevel.Administrator, Export_OnCommand);
CommandSystem.Register("ExportWSC", AccessLevel.Developer, Export_OnCommand);
}
[Usage("ExportWSC <file-path>")]
[Description("Exports all static items to a WSC file. This will delete all static items in the world. Please make a backup.")]
public static void Export_OnCommand(CommandEventArgs e)
{
var w = new StreamWriter(ExportFile);
if (e.Arguments.Length < 1)
{
e.Mobile.SendMessage("Usage: [ExportWSC <file-path>]");
return;
}
var exportFilePath = e.GetString(0);
var fi = new FileInfo(exportFilePath);
fi.Directory.EnsureDirectory();
var w = new StreamWriter(exportFilePath);
var remove = new List<Item>();
var count = 0;
e.Mobile.SendMessage($"Exporting all static items to \"{ExportFile}\"...");
e.Mobile.SendMessage($"Exporting all static items to \"{exportFilePath}\"...");
e.Mobile.SendMessage("This will delete all static items in the world. Please make a backup.");
foreach (var item in World.Items.Values)
@ -60,7 +70,7 @@ namespace Server.Commands
item.Delete();
}
e.Mobile.SendMessage($"Export complete. Exported {count} statics.");
e.Mobile.SendMessage($"Export complete. Exported {count} statics.");
}
}
}

View file

@ -15,7 +15,7 @@ public static class GenCommands
CommandSystem.Register("GenCommands", AccessLevel.Developer, GenCommandsWebpage_OnCommand);
}
[Usage("GenCommands [<command>]")]
[Usage("GenCommands")]
[Aliases("GenCmdWeb")]
[Description("Generates a webpage to the web folder with a list of all commands.")]
private static void GenCommandsWebpage_OnCommand(CommandEventArgs e)

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
using Server.Commands.Generic;
using Server.Gumps;
using Server.Network;
@ -87,36 +88,23 @@ public static class HelpInfo
var mi = e.Handler.Method;
var attrs = mi.GetCustomAttributes(typeof(UsageAttribute), false);
var usageAttr = mi.GetCustomAttribute(typeof(UsageAttribute), false) as UsageAttribute;
var usage = usageAttr?.Usage;
if (attrs.Length == 0)
{
continue;
}
var usage = attrs[0] as UsageAttribute;
attrs = mi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs.Length == 0)
{
continue;
}
if (usage == null || attrs[0] is not DescriptionAttribute desc)
{
continue;
}
attrs = mi.GetCustomAttributes(typeof(AliasesAttribute), false);
var aliases = attrs.Length == 0 ? null : attrs[0] as AliasesAttribute;
var descString = desc.Description
var descAttr = mi.GetCustomAttribute(typeof(DescriptionAttribute), false) as DescriptionAttribute;
var desc = descAttr?.Description
.ReplaceOrdinal("<", "(")
.ReplaceOrdinal(">", ")");
list.Add(new CommandInfo(e.AccessLevel, e.Command, aliases?.Aliases, usage.Usage, null, descString));
if (e.Handler.Target == null && usage == null && desc == null)
{
continue;
}
var aliasesAttr = mi.GetCustomAttribute(typeof(AliasesAttribute), false) as AliasesAttribute;
var aliases = aliasesAttr?.Aliases;
list.Add(new CommandInfo(e.AccessLevel, e.Command, aliases, usage, null, desc));
}
for (var i = 0; i < TargetCommands.AllCommands.Count; ++i)
@ -165,16 +153,11 @@ public static class HelpInfo
{
var command = commandImpls[i];
var usage = command.Usage;
var desc = command.Description;
if (usage == null || desc == null)
{
continue;
}
var cmds = command.Accessors;
var cmd = cmds[0];
var desc = command.Description ?? "No description available.";
var usage = command.Usage ?? cmd;
var aliases = new string[cmds.Length - 1];
for (var j = 0; j < aliases.Length; ++j)

View file

@ -24,7 +24,7 @@ namespace Server.Commands
}
[Usage("DecorateMag")]
[Description("Generates world decoration.")]
[Description("Generates world decoration for Magincia after it was ruined.")]
private static void DecorateMag_OnCommand(CommandEventArgs e)
{
m_Mobile = e.Mobile;