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

@ -21,7 +21,7 @@ public static class DumpNetStates
{
public static void Configure()
{
CommandSystem.Register("DumpNetStates", AccessLevel.Administrator, DumpNetStatesCommand);
CommandSystem.Register("DumpNetStates", AccessLevel.Developer, DumpNetStatesCommand);
}
public static void DumpNetStatesCommand(CommandEventArgs args)

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)

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;

View file

@ -1239,6 +1239,9 @@ namespace Server.Engines.ConPVP
CommandSystem.Register("vli", AccessLevel.GameMaster, vli_oc);
}
[Usage("vli")]
[Aliases("ViewLadderInfo")]
[Description("View ladder information.")]
private static void vli_oc(CommandEventArgs e)
{
e.Mobile.BeginTarget(-1, false, TargetFlags.None, vli_ot);

View file

@ -12,6 +12,8 @@ namespace Server.Engines.Doom
CommandSystem.Register("RemGauntlet", AccessLevel.Developer, RemoveGauntlet);
}
[Usage("RemGauntlet")]
[Description("Removes the Gauntlet from Dungeon Doom.")]
public static void RemoveGauntlet(CommandEventArgs e)
{
RemoveMobile<PricedHealer>(387, 400);
@ -45,6 +47,8 @@ namespace Server.Engines.Doom
RemoveItem<ConfirmationMoongate>(433, 326, 4);
}
[Usage("GenGauntlet")]
[Description("Generates the Gauntlet in Dungeon Doom.")]
public static void GenGauntlet_OnCommand(CommandEventArgs e)
{
RemoveGauntlet(e);

View file

@ -192,10 +192,11 @@ public partial class LeverPuzzleController : Item
public static void Configure()
{
CommandSystem.Register("GenLeverPuzzle", AccessLevel.Administrator, GenLampPuzzle_OnCommand);
CommandSystem.Register("GenLeverPuzzle", AccessLevel.Developer, GenLampPuzzle_OnCommand);
}
[Usage("GenLeverPuzzle"), Description("Generates lamp room and lever puzzle in doom.")]
[Usage("GenLeverPuzzle")]
[Description("Generates lamp room and lever puzzle in doom.")]
public static void GenLampPuzzle_OnCommand(CommandEventArgs e)
{
foreach (var item in Map.Malas.GetItemsAt(lp_Center))

View file

@ -657,6 +657,8 @@ namespace Server.Factions
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), ProcessTick);
}
[Usage("FactionTownReset")]
[Description("Resets all faction town data in the world.")]
public static void FactionTownReset_OnCommand(CommandEventArgs e)
{
var monoliths = BaseMonolith.Monoliths;
@ -715,6 +717,8 @@ namespace Server.Factions
}
}
[Usage("FactionReset")]
[Description("Resets all faction data in the world.")]
public static void FactionReset_OnCommand(CommandEventArgs e)
{
var monoliths = BaseMonolith.Monoliths;
@ -787,6 +791,8 @@ namespace Server.Factions
}
}
[Usage("FactionItemReset")]
[Description("Resets all faction items in the world.")]
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
var items = new List<Item>();
@ -869,6 +875,8 @@ namespace Server.Factions
}
}
[Usage("FactionElection")]
[Description("Opens the election properties for the targeted faction stone.")]
public static void FactionElection_OnCommand(CommandEventArgs e)
{
e.Mobile.SendMessage("Target a faction stone to open its election properties.");

View file

@ -9,6 +9,9 @@ namespace Server.Factions
CommandSystem.Register("GenerateFactions", AccessLevel.Developer, GenerateFactions_OnCommand);
}
[Usage("GenerateFactions")]
[Aliases("FactionGen", "GenFactions")]
[Description("Enables and generates factions.")]
public static void GenerateFactions_OnCommand(CommandEventArgs e)
{
var from = e.Mobile;

View file

@ -544,6 +544,8 @@ namespace Server.Factions
return null;
}
[Usage("GrantTownSilver <amount>")]
[Description("Grants silver to the town of the current region.")]
public static void GrantTownSilver_OnCommand(CommandEventArgs e)
{
var town = FromRegion(e.Mobile.Region);

View file

@ -113,6 +113,8 @@ namespace Server.Commands
m_Count++;
}
[Usage("GenKhaldun")]
[Description("Generates Khaldun Puzzles")]
public static void GenKhaldun_OnCommand(CommandEventArgs e)
{
m_Count = 0;

View file

@ -105,6 +105,8 @@ namespace Server.Engines.PartySystem
CommandSystem.Register("ListenToParty", AccessLevel.GameMaster, ListenToParty_OnCommand);
}
[Usage("ListenToParty")]
[Description("Listen to the targeted player's party chat.")]
public static void ListenToParty_OnCommand(CommandEventArgs e)
{
e.Mobile.BeginTarget(-1, false, TargetFlags.None, ListenToParty_OnTarget);

View file

@ -61,6 +61,8 @@ namespace Server
CommandSystem.Register("Path", AccessLevel.GameMaster, Path_OnCommand);
}
[Usage("Path")]
[Description("Draws a path from your current location to a targeted location.")]
public static void Path_OnCommand(CommandEventArgs e)
{
e.Mobile.BeginTarget(-1, true, TargetFlags.None, Path_OnTarget);

View file

@ -34,6 +34,8 @@ namespace Server.Engines.Spawners
CommandSystem.Register("ConvertPremiumSpawners", AccessLevel.Developer, ConvertPremiumSpawners_OnCommand);
}
[Usage("ConvertPremiumSpawners <relative search pattern to distribution> <output directory relative to distribution>")]
[Description("Converts Nerun's Premium Spawners to JSON.")]
private static void ConvertPremiumSpawners_OnCommand(CommandEventArgs args)
{
var from = args.Mobile;

View file

@ -1,18 +1,3 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: GenerateSpawnersCommand.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -37,6 +22,9 @@ namespace Server.Engines.Spawners
CommandSystem.Register("GenerateSpawners", AccessLevel.Developer, GenerateSpawners_OnCommand);
}
[Usage("GenerateSpawners <relative search pattern to distribution>")]
[Aliases("ImportSpawners", "GenSpawners", "GenSpawns")]
[Description("Generates spawners from JSON files. Supports basic globbing.")]
private static void GenerateSpawners_OnCommand(CommandEventArgs e)
{
var from = e.Mobile;

View file

@ -34,9 +34,12 @@ public class SpawnerControllerGump : GumpGrid
public static void Configure()
{
CommandSystem.Register("Spawn", AccessLevel.GameMaster, OpenSpawnGump_OnCommand);
CommandSystem.Register("SpawnAdmin", AccessLevel.GameMaster, OpenSpawnGump_OnCommand);
}
[Usage("Spawn")]
[Aliases("Spawn")]
[Description("Opens the spawn administration gump.")]
public static void OpenSpawnGump_OnCommand(CommandEventArgs e)
{
e.Mobile.SendGump(new SpawnerControllerGump(e.Mobile));

View file

@ -264,12 +264,23 @@ namespace Server.Gumps
AddButtonLabeled(20, 175, GetButtonID(3, 101), "Teleporters");
AddButtonLabeled(220, 175, GetButtonID(3, 102), "Moongates");
AddButtonLabeled(20, 200, GetButtonID(3, 103), "Generate Spawns");
AddButtonLabeled(220, 200, GetButtonID(3, 106), "Decoration");
AddButtonLabeled(20, 200, GetButtonID(3, 103), "Spawners");
AddButtonLabeled(220, 200, GetButtonID(3, 106), "Decorations");
AddButtonLabeled(20, 225, GetButtonID(3, 104), "Doors");
AddButtonLabeled(220, 225, GetButtonID(3, 105), "Signs");
AddButtonLabeled(20, 250, GetButtonID(3, 107), "Champions");
AddButtonLabeled(220, 250, GetButtonID(3, 108), "Magincia (AOS+)");
AddButtonLabeled(20, 275, GetButtonID(3, 109), "Stealable Artifacts");
AddButtonLabeled(220, 275, GetButtonID(3, 110), "SH Teleporters");
AddButtonLabeled(20, 300, GetButtonID(3, 111), "Secret Locations");
AddButtonLabeled(220, 300, GetButtonID(3, 112), "Doom");
AddButtonLabeled(20, 325, GetButtonID(3, 113), "Khaldun Puzzles");
goto case AdminGumpPage.Administer;
}
case AdminGumpPage.Administer_Server:
@ -400,9 +411,6 @@ namespace Server.Gumps
AddButtonLabeled(20, 250, GetButtonID(3, 408), "Squelch");
AddButtonLabeled(220, 250, GetButtonID(3, 409), "Unsquelch");
AddButtonLabeled(20, 270, GetButtonID(3, 410), "Freeze");
AddButtonLabeled(220, 270, GetButtonID(3, 411), "Unfreeze");
AddButtonLabeled(20, 290, GetButtonID(3, 412), "Hide");
AddButtonLabeled(220, 290, GetButtonID(3, 413), "Unhide");
@ -2135,20 +2143,50 @@ namespace Server.Gumps
case 106:
{
InvokeCommand("Decorate");
notice = "Decoration has been generated.";
notice = "Decorations have been generated.";
break;
}
case 107:
{
InvokeCommand("GenChamps");
notice = "Champions have been generated.";
break;
}
case 108:
{
InvokeCommand("DecorateMag");
notice = "Magincia Ruins decorations have been generated.";
break;
}
case 109:
{
InvokeCommand("GenStealArties");
notice = "Stealable Artifacts have been generated.";
break;
}
case 110:
{
InvokeCommand("Freeze");
notice = "Target bounding points.";
InvokeCommand("SHTelGen");
notice = "Solen Hive teleporters have been generated.";
break;
}
case 120:
case 111:
{
InvokeCommand("Unfreeze");
notice = "Target bounding points.";
InvokeCommand("SecretLocGen");
notice = "Secret Locations have been generated.";
break;
}
case 112:
{
InvokeCommand("GenLeverPuzzle");
InvokeCommand("GenGauntlet");
notice = "Doom has been generated.";
break;
}
case 113:
{
InvokeCommand("GenKhaldun");
notice = "Khaldun puzzles have been generated.";
break;
}
@ -2489,26 +2527,6 @@ namespace Server.Gumps
InvokeCommand("Add");
break;
}
case 111:
{
InvokeCommand("FreezeWorld");
break;
}
case 112:
{
InvokeCommand("FreezeMap");
break;
}
case 121:
{
InvokeCommand("UnfreezeWorld");
break;
}
case 122:
{
InvokeCommand("UnfreezeMap");
break;
}
}
break;

View file

@ -171,19 +171,8 @@ namespace Server.Items
[Usage("SHTelGen"), Description("Generates solen hives teleporters.")]
public static void SHTelGen_OnCommand(CommandEventArgs e)
{
World.Broadcast(0x35, true, "Solen hives teleporters are being generated, please wait.");
var startTime = Core.Now;
var count = new SHTeleporterCreator().CreateSHTeleporters();
var endTime = Core.Now;
World.Broadcast(
0x35,
true,
$"{count} solen hives teleporters have been created. The entire process took {(endTime - startTime).TotalSeconds:0.#} seconds."
);
CreateSHTeleporters();
e.Mobile.SendMessage("Solen Hive teleporters have been created.");
}
public void ChangeActive(bool active)
@ -259,12 +248,6 @@ namespace Server.Items
m_Changing = false;
}
public class SHTeleporterCreator
{
private int m_Count;
public SHTeleporterCreator() => m_Count = 0;
public static SHTeleporter FindSHTeleporter(Map map, Point3D p)
{
foreach (var teleporter in map.GetItemsAt<SHTeleporter>(p))
@ -278,7 +261,7 @@ namespace Server.Items
return null;
}
public SHTeleporter AddSHT(Map map, bool ext, int x, int y, int z)
public static SHTeleporter AddSHT(Map map, bool ext, int x, int y, int z)
{
var p = new Point3D(x, y, z);
var tele = FindSHTeleporter(map, p);
@ -287,8 +270,6 @@ namespace Server.Items
{
tele = new SHTeleporter(ext);
tele.MoveToWorld(p, map);
m_Count++;
}
return tele;
@ -300,7 +281,7 @@ namespace Server.Items
tele2.ChangeDest(tele1);
}
public void AddSHTCouple(Map map, bool ext1, int x1, int y1, int z1, bool ext2, int x2, int y2, int z2)
public static void AddSHTCouple(Map map, bool ext1, int x1, int y1, int z1, bool ext2, int x2, int y2, int z2)
{
var tele1 = AddSHT(map, ext1, x1, y1, z1);
var tele2 = AddSHT(map, ext2, x2, y2, z2);
@ -308,23 +289,21 @@ namespace Server.Items
Link(tele1, tele2);
}
public void AddSHTCouple(bool ext1, int x1, int y1, int z1, bool ext2, int x2, int y2, int z2)
public static void AddSHTCouple(bool ext1, int x1, int y1, int z1, bool ext2, int x2, int y2, int z2)
{
AddSHTCouple(Map.Trammel, ext1, x1, y1, z1, ext2, x2, y2, z2);
AddSHTCouple(Map.Felucca, ext1, x1, y1, z1, ext2, x2, y2, z2);
}
public int CreateSHTeleporters()
public static void CreateSHTeleporters()
{
SHTeleporter tele1, tele2;
AddSHTCouple(true, 2608, 763, 0, false, 5918, 1794, 0);
AddSHTCouple(false, 5897, 1877, 0, false, 5871, 1867, 0);
AddSHTCouple(false, 5852, 1848, 0, false, 5771, 1867, 0);
tele1 = AddSHT(Map.Trammel, false, 5747, 1895, 0);
var tele1 = AddSHT(Map.Trammel, false, 5747, 1895, 0);
tele1.LeftTele.TeleOffset = new Point3D(-1, 3, 0);
tele2 = AddSHT(Map.Trammel, false, 5658, 1898, 0);
var tele2 = AddSHT(Map.Trammel, false, 5658, 1898, 0);
Link(tele1, tele2);
tele1 = AddSHT(Map.Felucca, false, 5747, 1895, 0);
@ -378,9 +357,6 @@ namespace Server.Items
tele2 = AddSHT(Map.Felucca, true, 730, 1451, 0);
Link(tele1, tele2);
AddSHT(Map.Felucca, false, 5734, 1859, 0).ChangeDest(tele2);
return m_Count;
}
}
}
}

View file

@ -31,6 +31,8 @@ public partial class WayPoint : Item
CommandSystem.Register("WayPointSeq", AccessLevel.GameMaster, WayPointSeq_OnCommand);
}
[Usage("WayPointSeq")]
[Description("Creates a sequence of way points.")]
public static void WayPointSeq_OnCommand(CommandEventArgs arg)
{
arg.Mobile.SendMessage("Target the position of the first way point.");

View file

@ -57,6 +57,8 @@ namespace Server.Misc
CommandSystem.Register("Restart", AccessLevel.Administrator, Restart_OnCommand);
}
[Usage("Restart")]
[Description("Initiates a server restart. The world is not saved before the restart.")]
public static void Restart_OnCommand(CommandEventArgs e)
{
if (Restarting)

Binary file not shown.