style: apply formatter to buffer/registry/command/network files
This commit is contained in:
@@ -42,12 +42,12 @@ internal static class ClaimLinkBuffer
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (Cuboidi bufferCuboid in GetBuffer(groupId))
|
foreach (Cuboidi bufferCuboid in GetBuffer(groupId))
|
||||||
foreach (Cuboidi area in areas)
|
foreach (Cuboidi area in areas)
|
||||||
if (area.Intersects(bufferCuboid))
|
if (area.Intersects(bufferCuboid))
|
||||||
{
|
{
|
||||||
violatingGroupId = groupId;
|
violatingGroupId = groupId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
violatingGroupId = -1;
|
violatingGroupId = -1;
|
||||||
@@ -64,22 +64,19 @@ internal static class ClaimLinkBuffer
|
|||||||
HashSet<LandClaim> excludedClaims = new();
|
HashSet<LandClaim> excludedClaims = new();
|
||||||
if (excludeGroupIds != null)
|
if (excludeGroupIds != null)
|
||||||
foreach (int groupId in excludeGroupIds)
|
foreach (int groupId in excludeGroupIds)
|
||||||
foreach (string uid in ClaimLinkModSystem.Registry.MemberUidsForGroup(groupId))
|
foreach (string uid in ClaimLinkModSystem.Registry.MemberUidsForGroup(groupId))
|
||||||
foreach (
|
foreach (
|
||||||
int claimIndex in ClaimLinkModSystem.Registry.ClaimsForPlayerInGroup(
|
int claimIndex in ClaimLinkModSystem.Registry.ClaimsForPlayerInGroup(uid, groupId)
|
||||||
uid,
|
)
|
||||||
groupId
|
if (
|
||||||
)
|
ClaimLinkModSystem.TryResolveOwnedClaim(
|
||||||
|
uid,
|
||||||
|
claimIndex,
|
||||||
|
out LandClaim? excludedClaim
|
||||||
)
|
)
|
||||||
if (
|
&& excludedClaim != null
|
||||||
ClaimLinkModSystem.TryResolveOwnedClaim(
|
)
|
||||||
uid,
|
excludedClaims.Add(excludedClaim);
|
||||||
claimIndex,
|
|
||||||
out LandClaim? excludedClaim
|
|
||||||
)
|
|
||||||
&& excludedClaim != null
|
|
||||||
)
|
|
||||||
excludedClaims.Add(excludedClaim);
|
|
||||||
|
|
||||||
foreach (LandClaim claim in ClaimLinkModSystem.LandClaimAPI.All)
|
foreach (LandClaim claim in ClaimLinkModSystem.LandClaimAPI.All)
|
||||||
{
|
{
|
||||||
@@ -90,12 +87,12 @@ internal static class ClaimLinkBuffer
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (Cuboidi claimArea in claim.Areas)
|
foreach (Cuboidi claimArea in claim.Areas)
|
||||||
foreach (Cuboidi area in areas)
|
foreach (Cuboidi area in areas)
|
||||||
if (area.Intersects(claimArea))
|
if (area.Intersects(claimArea))
|
||||||
{
|
{
|
||||||
violatingClaim = claim;
|
violatingClaim = claim;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
violatingClaim = null;
|
violatingClaim = null;
|
||||||
@@ -105,7 +102,9 @@ internal static class ClaimLinkBuffer
|
|||||||
internal static ISet<int> MemberClaimLinkIds(string uid)
|
internal static ISet<int> MemberClaimLinkIds(string uid)
|
||||||
{
|
{
|
||||||
HashSet<int> groupIds = new();
|
HashSet<int> groupIds = new();
|
||||||
var memberships = ClaimLinkModSystem.PlayerData.GetPlayerDataByUid(uid)?.PlayerGroupMemberships;
|
var memberships = ClaimLinkModSystem
|
||||||
|
.PlayerData.GetPlayerDataByUid(uid)
|
||||||
|
?.PlayerGroupMemberships;
|
||||||
if (memberships == null)
|
if (memberships == null)
|
||||||
return groupIds;
|
return groupIds;
|
||||||
|
|
||||||
|
|||||||
@@ -644,7 +644,9 @@ public static class ClaimLinkChatCommand
|
|||||||
|
|
||||||
return ClaimLinkModSystem.Registry.RevokePlayer(group.Uid, targetUid)
|
return ClaimLinkModSystem.Registry.RevokePlayer(group.Uid, targetUid)
|
||||||
? TextCommandResult.Success($"Revoked {targetName}'s buffer access to '{group.Name}'.")
|
? TextCommandResult.Success($"Revoked {targetName}'s buffer access to '{group.Name}'.")
|
||||||
: TextCommandResult.Error($"{targetName} has no buffer access granted in '{group.Name}'.");
|
: TextCommandResult.Error(
|
||||||
|
$"{targetName} has no buffer access granted in '{group.Name}'."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextCommandResult ExecuteAllowGroup(
|
private static TextCommandResult ExecuteAllowGroup(
|
||||||
@@ -746,7 +748,11 @@ public static class ClaimLinkChatCommand
|
|||||||
|
|
||||||
public static TextCommandResult Deny(TextCommandCallingArgs args)
|
public static TextCommandResult Deny(TextCommandCallingArgs args)
|
||||||
{
|
{
|
||||||
TextCommandResult? err = ResolveClaimLinkFromWordPair(args, out PlayerGroup group, out string targetName);
|
TextCommandResult? err = ResolveClaimLinkFromWordPair(
|
||||||
|
args,
|
||||||
|
out PlayerGroup group,
|
||||||
|
out string targetName
|
||||||
|
);
|
||||||
if (err != null)
|
if (err != null)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -1170,7 +1176,11 @@ public static class ClaimLinkChatCommand
|
|||||||
|
|
||||||
public static TextCommandResult AdminDeny(TextCommandCallingArgs args)
|
public static TextCommandResult AdminDeny(TextCommandCallingArgs args)
|
||||||
{
|
{
|
||||||
TextCommandResult? err = ResolveClaimLinkFromWordPair(args, out PlayerGroup group, out string targetName);
|
TextCommandResult? err = ResolveClaimLinkFromWordPair(
|
||||||
|
args,
|
||||||
|
out PlayerGroup group,
|
||||||
|
out string targetName
|
||||||
|
);
|
||||||
if (err != null)
|
if (err != null)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ public class ClaimLinkRegistry
|
|||||||
private readonly Dictionary<string, Dictionary<int, List<int>>> entries = new();
|
private readonly Dictionary<string, Dictionary<int, List<int>>> entries = new();
|
||||||
private readonly Dictionary<int, Dictionary<string, EnumBlockAccessFlags>> permittedPlayerUids =
|
private readonly Dictionary<int, Dictionary<string, EnumBlockAccessFlags>> permittedPlayerUids =
|
||||||
new();
|
new();
|
||||||
private readonly Dictionary<int, Dictionary<int, EnumBlockAccessFlags>> permittedPlayerGroupIds =
|
private readonly Dictionary<
|
||||||
new();
|
int,
|
||||||
|
Dictionary<int, EnumBlockAccessFlags>
|
||||||
|
> permittedPlayerGroupIds = new();
|
||||||
|
|
||||||
public ClaimLinkRegistry(ISaveGame saveGame)
|
public ClaimLinkRegistry(ISaveGame saveGame)
|
||||||
{
|
{
|
||||||
@@ -43,7 +45,9 @@ public class ClaimLinkRegistry
|
|||||||
if (permission.PermittedPlayerUids.Count > 0)
|
if (permission.PermittedPlayerUids.Count > 0)
|
||||||
permittedPlayerUids[permission.GroupId] = new(permission.PermittedPlayerUids);
|
permittedPlayerUids[permission.GroupId] = new(permission.PermittedPlayerUids);
|
||||||
if (permission.PermittedPlayerGroupIds.Count > 0)
|
if (permission.PermittedPlayerGroupIds.Count > 0)
|
||||||
permittedPlayerGroupIds[permission.GroupId] = new(permission.PermittedPlayerGroupIds);
|
permittedPlayerGroupIds[permission.GroupId] = new(
|
||||||
|
permission.PermittedPlayerGroupIds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +129,9 @@ public class ClaimLinkRegistry
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, EnumBlockAccessFlags> PermittedPlayersForGroup(int groupId) =>
|
public IReadOnlyDictionary<string, EnumBlockAccessFlags> PermittedPlayersForGroup(
|
||||||
permittedPlayerUids.TryGetValue(groupId, out var uids) ? uids : EmptyPlayerFlags;
|
int groupId
|
||||||
|
) => permittedPlayerUids.TryGetValue(groupId, out var uids) ? uids : EmptyPlayerFlags;
|
||||||
|
|
||||||
public IReadOnlyDictionary<int, EnumBlockAccessFlags> PermittedGroupsForGroup(int groupId) =>
|
public IReadOnlyDictionary<int, EnumBlockAccessFlags> PermittedGroupsForGroup(int groupId) =>
|
||||||
permittedPlayerGroupIds.TryGetValue(groupId, out var groups) ? groups : EmptyGroupFlags;
|
permittedPlayerGroupIds.TryGetValue(groupId, out var groups) ? groups : EmptyGroupFlags;
|
||||||
|
|||||||
@@ -53,12 +53,11 @@ internal static class ClaimLinkVisualizerNetwork
|
|||||||
|
|
||||||
internal static void Start(ICoreServerAPI api)
|
internal static void Start(ICoreServerAPI api)
|
||||||
{
|
{
|
||||||
api.Network
|
api.Network.RegisterChannel(ChannelName)
|
||||||
.RegisterChannel(ChannelName)
|
|
||||||
.RegisterMessageType<ClaimLinkBufferRequest>()
|
.RegisterMessageType<ClaimLinkBufferRequest>()
|
||||||
.RegisterMessageType<ClaimLinkBufferResponse>()
|
.RegisterMessageType<ClaimLinkBufferResponse>()
|
||||||
.SetMessageHandler<ClaimLinkBufferRequest>((fromPlayer, _) =>
|
.SetMessageHandler<ClaimLinkBufferRequest>(
|
||||||
SendBuffers(api, fromPlayer)
|
(fromPlayer, _) => SendBuffers(api, fromPlayer)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user