feat: Adds Feature Flag System (#2328)
## Feature Flag System A runtime feature flag system for dynamically enabling/disabling game systems and blocking specific game elements without server restarts. ### Overview Two types of controls: 1. Feature Flags - Named boolean flags that gate entire systems (trading, PvP, vendors, housing, etc.) 2. Dynamic Blocks - Block specific gumps, items, skills, or spells by type All changes are persisted to JSON, broadcast to online staff, and bypass-able by administrators. ### Predefined Flags ``` ┌─────────────────┬──────────┬─────────────────────────────────────┐ │ Flag │ Category │ Description │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ player_trading │ Economy │ Allow secure trades between players │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ vendor_purchase │ Economy │ Allow purchasing from NPC vendors │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ vendor_sell │ Economy │ Allow selling to NPC vendors │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ player_vendors │ Economy │ Allow player vendor interactions │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ bank_access │ Economy │ Allow bank box access │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ house_placement │ Housing │ Allow new house placements │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ boat_placement │ Housing │ Allow new boat placements │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ bulk_orders │ Crafting │ Allow bulk order deeds │ ├─────────────────┼──────────┼─────────────────────────────────────┤ │ pvp_combat │ Combat │ Allow player vs player combat │ └─────────────────┴──────────┴─────────────────────────────────────┘ ``` ### Commands #### Feature Flags ``` ┌────────────────────────────────────────────────────┬───────────────────────┐ │ Command │ Description │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FeatureFlag <key> on|off|toggle|info │ Manage a feature flag │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FF <key> on|off │ Shorthand alias │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FeatureFlag <key> create <category> <desc> │ Create a custom flag │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FeatureFlag <key> delete │ Delete a custom flag │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FeatureList [flags|gumps|items|skills|spells|all] │ List all flags/blocks │ ├────────────────────────────────────────────────────┼───────────────────────┤ │ [FeatureAdmin │ Open the admin gump │ └────────────────────────────────────────────────────┴───────────────────────┘ ``` #### Gump Blocks ``` ┌────────────────────────────────┬──────────────────────────────────────────────────────┐ │ Command │ Description │ ├────────────────────────────────┼──────────────────────────────────────────────────────┤ │ [BlockGump <typeName> [reason] │ Block a gump type from displaying │ ├────────────────────────────────┼──────────────────────────────────────────────────────┤ │ [UnblockGump <typeName> │ Remove a gump block │ ├────────────────────────────────┼──────────────────────────────────────────────────────┤ │ [ListGumps [self] │ List open gumps on a player (for finding type names) │ └────────────────────────────────┴──────────────────────────────────────────────────────┘ ``` #### Item Blocks ``` ┌────────────────────────────────────────────────┬───────────────────────────────┐ │ Command │ Description │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [BlockItemUse <typeName|target> [reason] │ Block item use │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [BlockItemEquip <typeName|target> [reason] │ Block item equipping │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [BlockItemContainer <typeName|target> [reason] │ Block container access │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [UnblockItemUse <typeName> │ Remove use block │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [UnblockItemEquip <typeName> │ Remove equip block │ ├────────────────────────────────────────────────┼───────────────────────────────┤ │ [UnblockItemContainer <typeName> │ Remove container access block │ └────────────────────────────────────────────────┴───────────────────────────────┘ ``` Item block commands create an entry if one doesn't exist, or flip the relevant flag on an existing entry. Unblock commands only clear their specific flag -- the entry is removed when all flags (use/equip/container) are off. #### Skill & Spell Blocks ``` ┌──────────────────────────────────────┬──────────────────────┐ │ Command │ Description │ ├──────────────────────────────────────┼──────────────────────┤ │ [BlockSkill <SkillName> [reason] │ Block a skill │ ├──────────────────────────────────────┼──────────────────────┤ │ [UnblockSkill <SkillName> │ Remove a skill block │ ├──────────────────────────────────────┼──────────────────────┤ │ [BlockSpell <SpellTypeName> [reason] │ Block a spell │ ├──────────────────────────────────────┼──────────────────────┤ │ [UnblockSpell <SpellTypeName> │ Remove a spell block │ └──────────────────────────────────────┴──────────────────────┘ ``` ### Architecture - Static bool classes for hot-path checks (no dictionary lookups): ServerFeatureFlags (Server project) and ContentFeatureFlags (UOContent) - Synced automatically by FeatureFlagManager.SyncStaticFlag() when flags change - Predefined flags loaded from Distribution/Configuration/FeatureFlags/default-flags.json - Runtime state persisted to Configuration/FeatureFlags/*.json (flags, gump-blocks, item-blocks, skill-blocks, spell-blocks) - Admin gump with tabbed UI for managing all block types, per-entry PropertiesGump editing, and pagination - All staff at AccessLevel.GameMaster+ bypass dynamic blocks; AccessLevel.Administrator+ bypass feature flags ### Hook Points Hook: Player trading Location: Mobile.OpenTrade Mechanism: ServerFeatureFlags.PlayerTrading ──────────────────────────────────────── Hook: PvP combat Location: Mobile.CanBeHarmful Mechanism: ServerFeatureFlags.PvPCombat ──────────────────────────────────────── Hook: Bank access Location: BankBox.Open() Mechanism: ServerFeatureFlags.BankAccess ──────────────────────────────────────── Hook: Vendor buy/sell Location: BaseVendor Mechanism: ContentFeatureFlags.VendorPurchase/Sell ──────────────────────────────────────── Hook: Player vendors Location: PlayerVendor Mechanism: ContentFeatureFlags.PlayerVendors ──────────────────────────────────────── Hook: House placement Location: HousePlacement.Check() Mechanism: ContentFeatureFlags.HousePlacement (returns BadRegionTemp) ──────────────────────────────────────── Hook: Boat placement Location: BaseBoatDeed.OnDoubleClick/OnPlacement Mechanism: ContentFeatureFlags.BoatPlacement ──────────────────────────────────────── Hook: Bulk orders Location: SmallBOD/LargeBOD Mechanism: ContentFeatureFlags.BulkOrders ──────────────────────────────────────── Hook: Gump display Location: GumpSystem.SendGump Mechanism: FeatureFlagManager.IsGumpBlocked ──────────────────────────────────────── Hook: Item use Location: PlayerMobile.AllowItemUse Mechanism: FeatureFlagManager.IsItemUseBlocked ──────────────────────────────────────── Hook: Item equip Location: PlayerMobile.CheckEquip Mechanism: FeatureFlagManager.IsItemEquipBlocked ──────────────────────────────────────── Hook: Container access Location: BaseContainer.DisplayTo Mechanism: FeatureFlagManager.IsContainerAccessBlocked ──────────────────────────────────────── Hook: Skill use Location: PlayerMobile.AllowSkillUse Mechanism: FeatureFlagManager.IsSkillBlocked ──────────────────────────────────────── Hook: Spell casting Location: Spell.Cast / Spellbook.CastSpellRequest Mechanism: FeatureFlagManager.IsSpellBlocked
This commit is contained in:
parent
e4178bb495
commit
b191498569
25 changed files with 2461 additions and 117 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Engines.CannedEvil;
|
||||
using Server.Regions;
|
||||
using Server.Systems.FeatureFlags;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Multis;
|
||||
|
|
@ -66,64 +67,68 @@ public abstract partial class BaseBoatDeed : Item
|
|||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
var map = from.Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ContentFeatureFlags.BoatPlacement && from.AccessLevel < FeatureFlagSettings.RequiredAccessLevel)
|
||||
{
|
||||
from.SendMessage(0x22, "Boat placement is temporarily disabled.");
|
||||
}
|
||||
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
|
||||
{
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.Region.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(from.Location, from.Map) != null)
|
||||
{
|
||||
// You may not place a ship while on another ship or inside a house.
|
||||
from.SendLocalizedMessage(1010568, null, 0x25);
|
||||
return;
|
||||
}
|
||||
|
||||
var boat = Boat;
|
||||
|
||||
if (boat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
|
||||
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
|
||||
{
|
||||
Delete();
|
||||
|
||||
boat.Owner = from;
|
||||
boat.Anchored = true;
|
||||
|
||||
var keyValue = boat.CreateKeys(from);
|
||||
|
||||
if (boat.PPlank != null)
|
||||
{
|
||||
boat.PPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
if (boat.SPlank != null)
|
||||
{
|
||||
boat.SPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
boat.MoveToWorld(p, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
var map = from.Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
|
||||
{
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
return;
|
||||
}
|
||||
|
||||
if (from.Region.IsPartOf<HouseRegion>() || BaseBoat.FindBoatAt(from.Location, from.Map) != null)
|
||||
{
|
||||
// You may not place a ship while on another ship or inside a house.
|
||||
from.SendLocalizedMessage(1010568, null, 0x25);
|
||||
return;
|
||||
}
|
||||
|
||||
var boat = Boat;
|
||||
|
||||
if (boat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
|
||||
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
|
||||
{
|
||||
Delete();
|
||||
|
||||
boat.Owner = from;
|
||||
boat.Anchored = true;
|
||||
|
||||
var keyValue = boat.CreateKeys(from);
|
||||
|
||||
if (boat.PPlank != null)
|
||||
{
|
||||
boat.PPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
if (boat.SPlank != null)
|
||||
{
|
||||
boat.SPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
boat.MoveToWorld(p, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
boat.Delete();
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
}
|
||||
boat.Delete();
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using ModernUO.Serialization;
|
||||
using Server.Engines.CannedEvil;
|
||||
using Server.Regions;
|
||||
using Server.Systems.FeatureFlags;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Multis;
|
||||
|
|
@ -83,53 +84,58 @@ public abstract partial class BaseDockedBoat : Item
|
|||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
var map = from.Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var boat = Boat;
|
||||
|
||||
if (boat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ContentFeatureFlags.BoatPlacement && from.AccessLevel < FeatureFlagSettings.RequiredAccessLevel)
|
||||
{
|
||||
from.SendMessage(0x22, "Boat placement is temporarily disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
|
||||
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID) && map != Map.Ilshenar &&
|
||||
map != Map.Malas)
|
||||
{
|
||||
Delete();
|
||||
|
||||
boat.Owner = from;
|
||||
boat.Anchored = true;
|
||||
boat.ShipName = _shipName;
|
||||
|
||||
var keyValue = boat.CreateKeys(from);
|
||||
|
||||
if (boat.PPlank != null)
|
||||
{
|
||||
boat.PPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
if (boat.SPlank != null)
|
||||
{
|
||||
boat.SPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
boat.MoveToWorld(p, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
var map = from.Map;
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var boat = Boat;
|
||||
|
||||
if (boat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
|
||||
if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID) && map != Map.Ilshenar &&
|
||||
map != Map.Malas)
|
||||
{
|
||||
Delete();
|
||||
|
||||
boat.Owner = from;
|
||||
boat.Anchored = true;
|
||||
boat.ShipName = _shipName;
|
||||
|
||||
var keyValue = boat.CreateKeys(from);
|
||||
|
||||
if (boat.PPlank != null)
|
||||
{
|
||||
boat.PPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
if (boat.SPlank != null)
|
||||
{
|
||||
boat.SPlank.KeyValue = keyValue;
|
||||
}
|
||||
|
||||
boat.MoveToWorld(p, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
boat.Delete();
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
}
|
||||
boat.Delete();
|
||||
from.SendLocalizedMessage(1043284); // A ship can not be created here.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using Server.Collections;
|
||||
using Server.Regions;
|
||||
using Server.Spells;
|
||||
using Server.Systems.FeatureFlags;
|
||||
|
||||
namespace Server.Multis
|
||||
{
|
||||
|
|
@ -52,6 +53,11 @@ namespace Server.Multis
|
|||
return HousePlacementResult.BadLand; // A house cannot go here
|
||||
}
|
||||
|
||||
if (!ContentFeatureFlags.HousePlacement && from.AccessLevel < FeatureFlagSettings.RequiredAccessLevel)
|
||||
{
|
||||
return HousePlacementResult.BadRegionTemp;
|
||||
}
|
||||
|
||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
return HousePlacementResult.Valid; // Staff can place anywhere
|
||||
|
|
|
|||
|
|
@ -21,14 +21,13 @@ public partial class HousePlacementTool : Item
|
|||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendGump(new HousePlacementCategoryGump());
|
||||
}
|
||||
else
|
||||
if (!IsChildOf(from.Backpack))
|
||||
{
|
||||
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
|
||||
return;
|
||||
}
|
||||
|
||||
from.SendGump(new HousePlacementCategoryGump());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue