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)
|
private static string DescribeClaim(string ownerPlayerUid, int claimIndex)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
!ClaimLinkModSystem.TryResolveOwnedClaim(ownerPlayerUid, claimIndex, out LandClaim? claim)
|
!ClaimLinkModSystem.TryResolveOwnedClaim(
|
||||||
|
ownerPlayerUid,
|
||||||
|
claimIndex,
|
||||||
|
out LandClaim? claim
|
||||||
|
)
|
||||||
|| claim == null
|
|| claim == null
|
||||||
)
|
)
|
||||||
return $"claim {claimIndex}";
|
return $"claim {claimIndex}";
|
||||||
@@ -644,4 +648,9 @@ public static class ClaimLinkChatCommand
|
|||||||
|
|
||||||
public static TextCommandResult AdminInfo(TextCommandCallingArgs args) =>
|
public static TextCommandResult AdminInfo(TextCommandCallingArgs args) =>
|
||||||
TextCommandResult.Success("stub: claimlink admin info");
|
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 ClaimLinkRegistry Registry = null!;
|
||||||
internal static IGroupManager Groups = null!;
|
internal static IGroupManager Groups = null!;
|
||||||
internal static IWorldAccessor World = null!;
|
internal static IWorldAccessor World = null!;
|
||||||
internal ClaimLinkCommandListener? cmdListener;
|
internal ClaimLinkCommandListener? CmdListener;
|
||||||
|
|
||||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||||
|
|
||||||
@@ -24,17 +24,18 @@ public class ClaimLinkModSystem : ModSystem
|
|||||||
Groups = api.Groups;
|
Groups = api.Groups;
|
||||||
World = api.World;
|
World = api.World;
|
||||||
|
|
||||||
cmdListener = new ClaimLinkCommandListener();
|
CmdListener = new ClaimLinkCommandListener();
|
||||||
CommandHookModSystem.Register(cmdListener);
|
CommandHookModSystem.Register(CmdListener);
|
||||||
ClaimLinkChatCommand.Register(api);
|
ClaimLinkChatCommand.Register(api);
|
||||||
|
|
||||||
api.Event.PlayerDisconnect += ClaimLinkCommandListener.OnPlayerDisconnect;
|
api.Event.PlayerDisconnect += ClaimLinkCommandListener.OnPlayerDisconnect;
|
||||||
|
api.Event.PlayerDisconnect += ClaimLinkChatCommand.OnPlayerDisconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
if (cmdListener != null)
|
if (CmdListener != null)
|
||||||
CommandHookModSystem.Unregister(cmdListener);
|
CommandHookModSystem.Unregister(CmdListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<(int claimIndex, LandClaim claim)> EnumerateOwnedClaims(
|
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))
|
foreach ((int index, LandClaim c) in EnumerateOwnedClaims(ownerPlayerUid))
|
||||||
{
|
{
|
||||||
@@ -67,7 +72,11 @@ public class ClaimLinkModSystem : ModSystem
|
|||||||
return false;
|
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))
|
foreach ((int index, LandClaim c) in EnumerateOwnedClaims(ownerPlayerUid))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user