Skip to content

Commit

Permalink
fix: Fixes missing methods. Adds more admin gump world building (#1675)
Browse files Browse the repository at this point in the history
### 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%">
  • Loading branch information
kamronbatman committed Feb 11, 2024
1 parent cf98915 commit 4479555
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 211 deletions.
2 changes: 1 addition & 1 deletion Projects/Server/Network/NetState/DumpNetStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 16 additions & 6 deletions Projects/UOContent/Commands/ExportWSC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -60,7 +70,7 @@ public static void Export_OnCommand(CommandEventArgs e)
item.Delete();
}

e.Mobile.SendMessage($"Export complete. Exported {count} statics.");
e.Mobile.SendMessage($"Export complete. Exported {count} statics.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Commands/GenCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void Configure()
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)
Expand Down
45 changes: 14 additions & 31 deletions Projects/UOContent/Commands/HelpInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
using Server.Commands.Generic;
using Server.Gumps;
using Server.Network;
Expand Down Expand Up @@ -87,36 +88,23 @@ public static void FillTable()

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;
}
var descAttr = mi.GetCustomAttribute(typeof(DescriptionAttribute), false) as DescriptionAttribute;
var desc = descAttr?.Description
.ReplaceOrdinal("<", "(")
.ReplaceOrdinal(">", ")");

if (usage == null || attrs[0] is not DescriptionAttribute desc)
if (e.Handler.Target == null && usage == null && desc == null)
{
continue;
}

attrs = mi.GetCustomAttributes(typeof(AliasesAttribute), false);

var aliases = attrs.Length == 0 ? null : attrs[0] as AliasesAttribute;
var aliasesAttr = mi.GetCustomAttribute(typeof(AliasesAttribute), false) as AliasesAttribute;
var aliases = aliasesAttr?.Aliases;

var descString = desc.Description
.ReplaceOrdinal("<", "(")
.ReplaceOrdinal(">", ")");

list.Add(new CommandInfo(e.AccessLevel, e.Command, aliases?.Aliases, usage.Usage, null, descString));
list.Add(new CommandInfo(e.AccessLevel, e.Command, aliases, usage, null, desc));
}

for (var i = 0; i < TargetCommands.AllCommands.Count; ++i)
Expand Down Expand Up @@ -165,16 +153,11 @@ public static void FillTable()
{
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)
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Commands/Object Creation/DecorateMag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Configure()
}

[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;
Expand Down
3 changes: 3 additions & 0 deletions Projects/UOContent/Engines/ConPVP/DuelContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,9 @@ public static void Configure()
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);
Expand Down
4 changes: 4 additions & 0 deletions Projects/UOContent/Engines/Doom/GenGauntlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public static void Configure()
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);
Expand Down Expand Up @@ -45,6 +47,8 @@ public static void RemoveGauntlet(CommandEventArgs e)
RemoveItem<ConfirmationMoongate>(433, 326, 4);
}

[Usage("GenGauntlet")]
[Description("Generates the Gauntlet in Dungeon Doom.")]
public static void GenGauntlet_OnCommand(CommandEventArgs e)
{
RemoveGauntlet(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ public bool CircleComplete

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))
Expand Down
8 changes: 8 additions & 0 deletions Projects/UOContent/Engines/Factions/Core/Faction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ public static void Initialize()
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;
Expand Down Expand Up @@ -715,6 +717,8 @@ public static void FactionTownReset_OnCommand(CommandEventArgs e)
}
}

[Usage("FactionReset")]
[Description("Resets all faction data in the world.")]
public static void FactionReset_OnCommand(CommandEventArgs e)
{
var monoliths = BaseMonolith.Monoliths;
Expand Down Expand Up @@ -787,6 +791,8 @@ public static void FactionReset_OnCommand(CommandEventArgs e)
}
}

[Usage("FactionItemReset")]
[Description("Resets all faction items in the world.")]
public static void FactionItemReset_OnCommand(CommandEventArgs e)
{
var items = new List<Item>();
Expand Down Expand Up @@ -869,6 +875,8 @@ public static void FactionCommander_OnTarget(Mobile from, object obj)
}
}

[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.");
Expand Down
3 changes: 3 additions & 0 deletions Projects/UOContent/Engines/Factions/Core/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public static void Configure()
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;
Expand Down
2 changes: 2 additions & 0 deletions Projects/UOContent/Engines/Factions/Core/Town.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ public static Town Parse(string name)
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);
Expand Down
2 changes: 2 additions & 0 deletions Projects/UOContent/Engines/Khaldun/KhaldunGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public static void CreateBigTeleporterItem(int x, int y, bool reverse)
m_Count++;
}

[Usage("GenKhaldun")]
[Description("Generates Khaldun Puzzles")]
public static void GenKhaldun_OnCommand(CommandEventArgs e)
{
m_Count = 0;
Expand Down
2 changes: 2 additions & 0 deletions Projects/UOContent/Engines/Party/Party.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public static void Configure()
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);
Expand Down
2 changes: 2 additions & 0 deletions Projects/UOContent/Engines/Pathing/MovementPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static void Configure()
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static void Configure()
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -37,6 +22,9 @@ public static void Configure()
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;
Expand Down
5 changes: 4 additions & 1 deletion Projects/UOContent/Engines/Spawners/SpawnerControllerGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 4479555

Please sign in to comment.