feat: stub out full /land command surface as hook points

Table-drives dispatch for every vanilla /land subcommand (free,
info, list, adminfree, claim's new/grant/revoke/grow/shrink/etc.)
so each has a named hook to fill in.
This commit is contained in:
2026-07-12 16:16:25 +02:00
parent 5c7fa58ea2
commit 1baa20022b
+80 -23
View File
@@ -15,21 +15,54 @@ public class ClaimLinkCommandListener : ICommandHookListener
private static Dictionary<string, int> pendingLoads = new Dictionary<string, int>(); private static Dictionary<string, int> pendingLoads = new Dictionary<string, int>();
private delegate void SubHandler(Caller caller, CmdArgs args);
private static readonly Dictionary<string, SubHandler> topLevel = new()
{
["claim"] = Claim,
["free"] = Free,
["info"] = Info,
["list"] = List,
["adminfree"] = AdminFree,
};
private static readonly Dictionary<string, SubHandler> claimSub = new()
{
["load"] = ClaimLoad,
["new"] = ClaimNew,
["grant"] = ClaimGrant,
["revoke"] = ClaimRevoke,
["grantgroup"] = ClaimGrantGroup,
["revokegroup"] = ClaimRevokeGroup,
["start"] = ClaimStart,
["end"] = ClaimEnd,
["grow"] = ClaimGrow,
["shrink"] = ClaimShrink,
["add"] = ClaimAdd,
["allowuseeveryone"] = ClaimAllowUseEveryone,
["plevel"] = ClaimPLevel,
["fullheight"] = ClaimFullHeight,
["save"] = ClaimSave,
["cancel"] = ClaimCancel,
["download"] = ClaimDownload,
};
private TextCommandResult? Before(TextCommandCallingArgs args) private TextCommandResult? Before(TextCommandCallingArgs args)
{ {
CmdArgs rawArgs = args.RawArgs.Clone(); CmdArgs rawArgs = args.RawArgs.Clone();
while (rawArgs.Length > 0) while (rawArgs.Length > 0)
{ {
switch (rawArgs.PeekWord()) string word = rawArgs.PeekWord();
if (topLevel.TryGetValue(word, out SubHandler handler))
{ {
case "claim":
rawArgs.PopWord(); rawArgs.PopWord();
handleClaim(args.Caller, rawArgs); handler(args.Caller, rawArgs);
break; }
default: else
{
rawArgs.PopWord(); rawArgs.PopWord();
break;
} }
} }
@@ -40,18 +73,25 @@ public class ClaimLinkCommandListener : ICommandHookListener
{ {
} }
private void handleClaim(Caller caller, CmdArgs args) private static void Claim(Caller caller, CmdArgs args)
{ {
switch (args.PeekWord()) string word = args.PeekWord();
{
case "load":
if (caller.Player == null)
break;
if (claimSub.TryGetValue(word, out SubHandler handler))
{
args.PopWord(); args.PopWord();
handler(caller, args);
}
}
private static void ClaimLoad(Caller caller, CmdArgs args)
{
if (caller.Player == null)
return;
int? claimIndex = args.PopInt(); int? claimIndex = args.PopInt();
if (claimIndex == null || claimIndex < 0 || claimIndex > 999) if (claimIndex == null || claimIndex < 0 || claimIndex > 999)
break; return;
List<LandClaim> claims = ClaimLinkModSystem.LandClaimAPI.All, ownedClaims = new List<LandClaim>(); List<LandClaim> claims = ClaimLinkModSystem.LandClaimAPI.All, ownedClaims = new List<LandClaim>();
List<int> globalIndex = new List<int>(); List<int> globalIndex = new List<int>();
@@ -65,25 +105,42 @@ public class ClaimLinkCommandListener : ICommandHookListener
} }
if (claimIndex >= ownedClaims.Count) if (claimIndex >= ownedClaims.Count)
break; return;
pendingLoads[caller.Player.PlayerUID] = globalIndex[(int)claimIndex]; pendingLoads[caller.Player.PlayerUID] = globalIndex[(int)claimIndex];
break; }
case "cancel":
private static void ClaimCancel(Caller caller, CmdArgs args)
{
if (caller.Player == null) if (caller.Player == null)
break; return;
args.PopWord();
pendingLoads.Remove(caller.Player.PlayerUID); pendingLoads.Remove(caller.Player.PlayerUID);
break;
default:
break;
}
} }
private static void Free(Caller caller, CmdArgs args) { }
private static void Info(Caller caller, CmdArgs args) { }
private static void List(Caller caller, CmdArgs args) { }
private static void AdminFree(Caller caller, CmdArgs args) { }
private static void ClaimNew(Caller caller, CmdArgs args) { }
private static void ClaimGrant(Caller caller, CmdArgs args) { }
private static void ClaimRevoke(Caller caller, CmdArgs args) { }
private static void ClaimGrantGroup(Caller caller, CmdArgs args) { }
private static void ClaimRevokeGroup(Caller caller, CmdArgs args) { }
private static void ClaimStart(Caller caller, CmdArgs args) { }
private static void ClaimEnd(Caller caller, CmdArgs args) { }
private static void ClaimGrow(Caller caller, CmdArgs args) { }
private static void ClaimShrink(Caller caller, CmdArgs args) { }
private static void ClaimAdd(Caller caller, CmdArgs args) { }
private static void ClaimAllowUseEveryone(Caller caller, CmdArgs args) { }
private static void ClaimPLevel(Caller caller, CmdArgs args) { }
private static void ClaimFullHeight(Caller caller, CmdArgs args) { }
private static void ClaimSave(Caller caller, CmdArgs args) { }
private static void ClaimDownload(Caller caller, CmdArgs args) { }
internal static void OnPlayerDisconnect(IServerPlayer player) internal static void OnPlayerDisconnect(IServerPlayer player)
{ {
pendingLoads.Remove(player.PlayerUID); pendingLoads.Remove(player.PlayerUID);
} }
} }