refactor: clear pending actions in claim link command instead of land claim listener
This commit is contained in:
@@ -574,7 +574,11 @@ public static class ClaimLinkChatCommand
|
||||
private static string DescribeClaim(string ownerPlayerUid, int claimIndex)
|
||||
{
|
||||
if (
|
||||
!ClaimLinkModSystem.TryResolveOwnedClaim(ownerPlayerUid, claimIndex, out LandClaim? claim)
|
||||
!ClaimLinkModSystem.TryResolveOwnedClaim(
|
||||
ownerPlayerUid,
|
||||
claimIndex,
|
||||
out LandClaim? claim
|
||||
)
|
||||
|| claim == null
|
||||
)
|
||||
return $"claim {claimIndex}";
|
||||
@@ -644,4 +648,9 @@ public static class ClaimLinkChatCommand
|
||||
|
||||
public static TextCommandResult AdminInfo(TextCommandCallingArgs args) =>
|
||||
TextCommandResult.Success("stub: claimlink admin info");
|
||||
|
||||
internal static void OnPlayerDisconnect(IServerPlayer player)
|
||||
{
|
||||
PendingActions.Remove(player.PlayerUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ClaimLinkModSystem : ModSystem
|
||||
internal static ClaimLinkRegistry Registry = null!;
|
||||
internal static IGroupManager Groups = null!;
|
||||
internal static IWorldAccessor World = null!;
|
||||
internal ClaimLinkCommandListener? cmdListener;
|
||||
internal ClaimLinkCommandListener? CmdListener;
|
||||
|
||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||
|
||||
@@ -24,17 +24,18 @@ public class ClaimLinkModSystem : ModSystem
|
||||
Groups = api.Groups;
|
||||
World = api.World;
|
||||
|
||||
cmdListener = new ClaimLinkCommandListener();
|
||||
CommandHookModSystem.Register(cmdListener);
|
||||
CmdListener = new ClaimLinkCommandListener();
|
||||
CommandHookModSystem.Register(CmdListener);
|
||||
ClaimLinkChatCommand.Register(api);
|
||||
|
||||
api.Event.PlayerDisconnect += ClaimLinkCommandListener.OnPlayerDisconnect;
|
||||
api.Event.PlayerDisconnect += ClaimLinkChatCommand.OnPlayerDisconnect;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (cmdListener != null)
|
||||
CommandHookModSystem.Unregister(cmdListener);
|
||||
if (CmdListener != null)
|
||||
CommandHookModSystem.Unregister(CmdListener);
|
||||
}
|
||||
|
||||
private static IEnumerable<(int claimIndex, LandClaim claim)> EnumerateOwnedClaims(
|
||||
@@ -52,7 +53,11 @@ public class ClaimLinkModSystem : ModSystem
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool TryResolveOwnedClaim(string ownerPlayerUid, int claimIndex, out LandClaim? claim)
|
||||
internal static bool TryResolveOwnedClaim(
|
||||
string ownerPlayerUid,
|
||||
int claimIndex,
|
||||
out LandClaim? claim
|
||||
)
|
||||
{
|
||||
foreach ((int index, LandClaim c) in EnumerateOwnedClaims(ownerPlayerUid))
|
||||
{
|
||||
@@ -67,7 +72,11 @@ public class ClaimLinkModSystem : ModSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool TryResolveClaimIndex(string ownerPlayerUid, LandClaim target, out int claimIndex)
|
||||
internal static bool TryResolveClaimIndex(
|
||||
string ownerPlayerUid,
|
||||
LandClaim target,
|
||||
out int claimIndex
|
||||
)
|
||||
{
|
||||
foreach ((int index, LandClaim c) in EnumerateOwnedClaims(ownerPlayerUid))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user