Fix commands
This commit is contained in:
@@ -186,14 +186,15 @@ public class CommandService : IDisposable
|
|||||||
if (!isTurningOffAllProfiles)
|
if (!isTurningOffAllProfiles)
|
||||||
{
|
{
|
||||||
profileName = subArgumentList[1].Trim();
|
profileName = subArgumentList[1].Trim();
|
||||||
foreach(var profile in _profileManager.Profiles)
|
foreach (var profile in _profileManager.Profiles)
|
||||||
{
|
{
|
||||||
if (!profile.Characters.Any(x => x.ToNameWithoutOwnerName() == characterName))
|
if (!profile.Characters.Any(x => x.ToNameWithoutOwnerName() == characterName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (profile.Name != profileName)
|
if (profile.Name != profileName)
|
||||||
{
|
{
|
||||||
profilesToDisable.Add(profile);
|
if(profile.Enabled)
|
||||||
|
profilesToDisable.Add(profile);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ public class CommandService : IDisposable
|
|||||||
else
|
else
|
||||||
profilesToDisable = _profileManager.Profiles.Where(x => x.Characters.Any(x => x.ToNameWithoutOwnerName() == characterName) && x.Enabled).ToList();
|
profilesToDisable = _profileManager.Profiles.Where(x => x.Characters.Any(x => x.ToNameWithoutOwnerName() == characterName) && x.Enabled).ToList();
|
||||||
|
|
||||||
if (targetProfile == null || (isTurningOffAllProfiles && profilesToDisable.Count == 0))
|
if((!isTurningOffAllProfiles && targetProfile == null) || (isTurningOffAllProfiles && profilesToDisable.Count == 0))
|
||||||
{
|
{
|
||||||
_chatService.PrintInChat(new SeStringBuilder()
|
_chatService.PrintInChat(new SeStringBuilder()
|
||||||
.AddText("Cannot execute command because profile ")
|
.AddText("Cannot execute command because profile ")
|
||||||
@@ -214,39 +215,56 @@ public class CommandService : IDisposable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != null)
|
if(!isTurningOffAllProfiles)
|
||||||
{
|
{
|
||||||
if(targetProfile.Enabled == state)
|
if (state != null)
|
||||||
{
|
{
|
||||||
_chatService.PrintInChat(new SeStringBuilder()
|
if (targetProfile!.Enabled == state)
|
||||||
.AddText("Profile ")
|
{
|
||||||
.AddYellow(targetProfile.Name)
|
_chatService.PrintInChat(new SeStringBuilder()
|
||||||
.AddText(" for ")
|
.AddText("Profile ")
|
||||||
.AddBlue(characterName)
|
.AddYellow(targetProfile.Name)
|
||||||
.AddText(" is already ")
|
.AddText(" for ")
|
||||||
.AddGreen((bool)state ? "enabled" : "disabled").BuiltString);
|
.AddBlue(characterName)
|
||||||
return;
|
.AddText(" is already ")
|
||||||
|
.AddGreen((bool)state ? "enabled" : "disabled").BuiltString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_profileManager.SetEnabled(targetProfile, (bool)state);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
_profileManager.SetEnabled(targetProfile, (bool)state);
|
_profileManager.SetEnabled(targetProfile!, !targetProfile!.Enabled);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
_profileManager.SetEnabled(targetProfile, !targetProfile.Enabled);
|
if (isTurningOffAllProfiles || targetProfile!.Enabled)
|
||||||
|
|
||||||
if(targetProfile.Enabled)
|
|
||||||
{
|
{
|
||||||
foreach (var profile in profilesToDisable)
|
foreach (var profile in profilesToDisable)
|
||||||
_profileManager.SetEnabled(profile, false);
|
_profileManager.SetEnabled(profile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pluginConfiguration.CommandSettings.PrintSuccessMessages)
|
if (_pluginConfiguration.CommandSettings.PrintSuccessMessages)
|
||||||
_chatService.PrintInChat(new SeStringBuilder()
|
{
|
||||||
.AddText("Profile ")
|
if (isTurningOffAllProfiles)
|
||||||
.AddYellow(targetProfile.Name)
|
_chatService.PrintInChat(new SeStringBuilder()
|
||||||
.AddText(" was successfully ")
|
.AddYellow($"{profilesToDisable.Count} profile(s)")
|
||||||
.AddBlue(state != null ? ((bool)state ? "enabled" : "disabled") : "toggled")
|
.AddText(" successfully ")
|
||||||
.AddText(" for ")
|
.AddBlue("disabled")
|
||||||
.AddRed(string.Join(',', targetProfile.Characters.Select(x => x.ToNameWithoutOwnerName()))).BuiltString);
|
.AddText(" for ")
|
||||||
|
.AddRed(characterName).BuiltString);
|
||||||
|
else
|
||||||
|
_chatService.PrintInChat(new SeStringBuilder()
|
||||||
|
.AddText("Profile ")
|
||||||
|
.AddYellow(targetProfile!.Name)
|
||||||
|
.AddText(" was successfully ")
|
||||||
|
.AddBlue(state != null ? ((bool)state ? "enabled" : "disabled") : "toggled")
|
||||||
|
.AddText(" for ")
|
||||||
|
.AddRed(string.Join(',', targetProfile.Characters.Select(x => x.ToNameWithoutOwnerName())))
|
||||||
|
.AddText(". ")
|
||||||
|
.AddItalics($"({profilesToDisable.Count} profile(s) disabled)")
|
||||||
|
.BuiltString);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user