### Summary - Fixes `[AdvancedSearch` being accessible by players 😱 - Adds `[GenCommands` to generate the same commands html page on https://muo.gg/commands. - Fixes `[helpinfo` so all commands properly show up! > [!WARNING] > ### Developer Warning: > Commands must now be registered in the `Configure` bootup phase. > If a command is not registered early enough, it may not be available to systems like [helpinfo > that cache their information. > [!NOTE] > ### Developer Note: > Various commands related to generating content have been changed to _Developer_ and above access level. ### Screenshots <img width="673" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/b105b5c9-5eb4-4ace-93ff-1bfb31e7132f"> <img width="547" alt="image" src="https://github.com/modernuo/ModernUO/assets/3953314/e97487e8-47a5-4aa7-89cc-9fe3deda584d">
98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Server.Mobiles;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Engines.Craft;
|
|
|
|
public class Recipe
|
|
{
|
|
private TextDefinition _td;
|
|
|
|
public Recipe(int id, CraftSystem system, CraftItem item)
|
|
{
|
|
ID = id;
|
|
CraftSystem = system;
|
|
CraftItem = item;
|
|
|
|
if (!Recipes.TryAdd(id, this))
|
|
{
|
|
throw new Exception("Attempting to create recipe with preexisting ID.");
|
|
}
|
|
|
|
LargestRecipeID = Math.Max(id, LargestRecipeID);
|
|
}
|
|
|
|
public static Dictionary<int, Recipe> Recipes { get; } = new();
|
|
|
|
public static int LargestRecipeID { get; private set; }
|
|
|
|
public CraftSystem CraftSystem { get; set; }
|
|
|
|
public CraftItem CraftItem { get; set; }
|
|
|
|
public int ID { get; }
|
|
|
|
public TextDefinition TextDefinition => _td ??= TextDefinition.Of(CraftItem.NameNumber, CraftItem.NameString);
|
|
|
|
public static void Configure()
|
|
{
|
|
CommandSystem.Register("LearnAllRecipes", AccessLevel.GameMaster, LearnAllRecipes_OnCommand);
|
|
CommandSystem.Register("ForgetAllRecipes", AccessLevel.GameMaster, ForgetAllRecipes_OnCommand);
|
|
}
|
|
|
|
[Usage("LearnAllRecipes"), Description("Teaches a player all available recipes.")]
|
|
private static void LearnAllRecipes_OnCommand(CommandEventArgs e)
|
|
{
|
|
var m = e.Mobile;
|
|
m.SendMessage("Target a player to teach them all of the recipes.");
|
|
|
|
m.BeginTarget(
|
|
-1,
|
|
false,
|
|
TargetFlags.None,
|
|
(from, targeted) =>
|
|
{
|
|
if (targeted is PlayerMobile mobile)
|
|
{
|
|
foreach (var kvp in Recipes)
|
|
{
|
|
mobile.AcquireRecipe(kvp.Key);
|
|
}
|
|
|
|
from.SendMessage("You teach them all of the recipes.");
|
|
}
|
|
else
|
|
{
|
|
from.SendMessage("That is not a player!");
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
[Usage("ForgetAllRecipes"), Description("Makes a player forget all the recipes they've learned.")]
|
|
private static void ForgetAllRecipes_OnCommand(CommandEventArgs e)
|
|
{
|
|
var m = e.Mobile;
|
|
m.SendMessage("Target a player to have them forget all of the recipes they've learned.");
|
|
|
|
m.BeginTarget(
|
|
-1,
|
|
false,
|
|
TargetFlags.None,
|
|
(from, targeted) =>
|
|
{
|
|
if (targeted is PlayerMobile mobile)
|
|
{
|
|
mobile.ResetRecipes();
|
|
|
|
from.SendMessage("They forget all their recipes.");
|
|
}
|
|
else
|
|
{
|
|
from.SendMessage("That is not a player!");
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|