feat: implement claimlink info, bump to 0.0.4
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Server;
|
||||
|
||||
@@ -294,7 +295,35 @@ public static class ClaimLinkChatCommand
|
||||
}
|
||||
public static TextCommandResult Delete(TextCommandCallingArgs args) => TextCommandResult.Success("stub: claimlink delete");
|
||||
public static TextCommandResult TransferOwnership(TextCommandCallingArgs args) => TextCommandResult.Success("stub: claimlink transferownership");
|
||||
public static TextCommandResult Info(TextCommandCallingArgs args) => TextCommandResult.Success("stub: claimlink info");
|
||||
public static TextCommandResult Info(TextCommandCallingArgs args)
|
||||
{
|
||||
string groupName = (string)args[0];
|
||||
|
||||
TextCommandResult? err = TryResolveGroup(groupName, out PlayerGroup group);
|
||||
if (err != null) return err;
|
||||
|
||||
err = TryResolveClaimLink(group, out ClaimLink link);
|
||||
if (err != null) return err;
|
||||
|
||||
err = RequireOpOrOwner(args.Caller.Player, group);
|
||||
if (err != null) return err;
|
||||
|
||||
return TextCommandResult.Success(FormatInfo(groupName, link));
|
||||
}
|
||||
|
||||
private static string FormatInfo(string groupName, ClaimLink link)
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.AppendLine($"Claim link '{groupName}' ({link.Members.Count} member(s)):");
|
||||
|
||||
foreach (ClaimLinkMember member in link.Members)
|
||||
{
|
||||
string name = ClaimLinkModSystem.World.PlayerByUid(member.OwnerPlayerUid)?.PlayerName ?? member.OwnerPlayerUid;
|
||||
sb.AppendLine($" {name}: claims [{string.Join(", ", member.LocalClaimIndices)}]");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static TextCommandResult AdminDelete(TextCommandCallingArgs args) => TextCommandResult.Success("stub: claimlink admin delete");
|
||||
public static TextCommandResult AdminUnlink(TextCommandCallingArgs args) => TextCommandResult.Success("stub: claimlink admin unlink");
|
||||
|
||||
@@ -11,6 +11,7 @@ public class ClaimLinkModSystem : ModSystem
|
||||
internal static ILogger Logger = null!;
|
||||
internal static ClaimLinkRegistry Registry = null!;
|
||||
internal static IGroupManager Groups = null!;
|
||||
internal static IWorldAccessor World = null!;
|
||||
internal ClaimLinkCommandListener? cmdListener;
|
||||
|
||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||
@@ -21,6 +22,7 @@ public class ClaimLinkModSystem : ModSystem
|
||||
Logger = api.Logger;
|
||||
Registry = new ClaimLinkRegistry(api.WorldManager.SaveGame);
|
||||
Groups = api.Groups;
|
||||
World = api.World;
|
||||
|
||||
cmdListener = new ClaimLinkCommandListener();
|
||||
CommandHookModSystem.Register(cmdListener);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"anth64"
|
||||
],
|
||||
"description": "Link claims together with groups.",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"dependencies": {
|
||||
"game": "1.22.3",
|
||||
"commandhook": "2.1.0"
|
||||
|
||||
Reference in New Issue
Block a user