prevent same level clients from demoting each other

This commit is contained in:
RaidMax 2019-08-08 15:58:23 -05:00
parent 1c66ac9117
commit 2ba0b1e7d3

View File

@ -489,9 +489,8 @@ namespace SharedLibraryCore.Commands
public override Task ExecuteAsync(GameEvent E)
{
EFClient.Permission oldPerm = E.Target.Level;
EFClient.Permission newPerm = Utilities.MatchPermission(E.Data);
Permission oldPerm = E.Target.Level;
Permission newPerm = Utilities.MatchPermission(E.Data);
if (E.Target == E.Origin)
{
@ -499,8 +498,7 @@ namespace SharedLibraryCore.Commands
return Task.CompletedTask;
}
else if (newPerm == EFClient.Permission.Owner &&
else if (newPerm == Permission.Owner &&
!E.Owner.Manager.GetApplicationSettings().Configuration().EnableMultipleOwners)
{
// only one owner is allowed
@ -508,7 +506,7 @@ namespace SharedLibraryCore.Commands
return Task.CompletedTask;
}
else if (E.Origin.Level < EFClient.Permission.Owner &&
else if (E.Origin.Level < Permission.Owner &&
!E.Owner.Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy)
{
// only the owner is allowed to set levels
@ -516,15 +514,17 @@ namespace SharedLibraryCore.Commands
return Task.CompletedTask;
}
else if (E.Origin.Level <= newPerm &&
E.Origin.Level < EFClient.Permission.Owner)
else if ((E.Origin.Level <= newPerm &&
E.Origin.Level < Permission.Owner) ||
E.Origin.Level == newPerm)
{
// can't promote a client to higher than your current perms
// or your peer
E.Origin.Tell(string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_SETLEVEL_LEVELTOOHIGH"], E.Target.Name, (E.Origin.Level - 1).ToString()));
return Task.CompletedTask;
}
else if (newPerm > EFClient.Permission.Banned)
else if (newPerm > Permission.Banned)
{
var ActiveClient = E.Owner.Manager.GetActiveClients()
.FirstOrDefault(p => p.NetworkId == E.Target.NetworkId);