update version, and add support for renaming default rank names through ClanTagCommands.json

This commit is contained in:
INSANEMODE
2020-11-20 04:05:14 -06:00
parent eed006b0fe
commit 50a6c83913
6 changed files with 99 additions and 33 deletions

View File

@ -3,6 +3,7 @@ using SharedLibraryCore.Commands;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Interfaces;
using System;
using System.Threading.Tasks;
@ -17,10 +18,20 @@ namespace ClanTagRankApi.Commands
readonly string rank = "rank";
string rank_string;
private readonly IMetaService _metaService;
private readonly IConfigurationHandler<Configuration> _configurationHandler;
private Configuration Config;
public ResetRankCommand(CommandConfiguration config, ITranslationLookup lookup, IMetaService metaService) : base(config, lookup)
public ResetRankCommand(CommandConfiguration config, ITranslationLookup lookup, IMetaService metaService, IConfigurationHandlerFactory configurationHandlerFactory) : base(config, lookup)
{
_metaService = metaService;
_configurationHandler = configurationHandlerFactory.GetConfigurationHandler<Configuration>("ClanTagRankCommands");
if (_configurationHandler.Configuration() == null)
{
_configurationHandler.Set((Configuration)new Configuration().Generate());
_configurationHandler.Save();
}
Config = _configurationHandler.Configuration();
Name = "ResetRank";
Description = "set a user's clan tag Rank (does not give permissions)";
Alias = "rr";
@ -41,7 +52,7 @@ namespace ClanTagRankApi.Commands
//var S = E.Owner;
rank_string = "none";
await _metaService.AddPersistentMeta(rank, rank_string, E.Target);
rank_string = E.Target.Level.ClanTag();
rank_string = E.Target.Level.ClanTag(Config);
E.Origin.Tell(E.Target.Name + "'s rank has been reset to: " + rank_string);
await E.Owner.ExecuteCommandAsync("setrank" + " " + E.Target.ClientNumber + " " + rank_string);
}

View File

@ -6,21 +6,34 @@ using SharedLibraryCore.Interfaces;
using System.Threading.Tasks;
namespace ClanTagRankApi.Commands
{
/// <summary>
/// Example script command
/// </summary>
///
public class SetRankCommand : Command
{
readonly string rank = "rank";
string rank_string;
private readonly IMetaService _metaService;
private readonly IConfigurationHandler<Configuration> _configurationHandler;
private Configuration Config;
public SetRankCommand(CommandConfiguration config, ITranslationLookup lookup, IMetaService metaService) : base(config, lookup)
public SetRankCommand(CommandConfiguration config, ITranslationLookup lookup, IMetaService metaService, IConfigurationHandlerFactory configurationHandlerFactory) : base(config, lookup)
{
_metaService = metaService;
_configurationHandler = configurationHandlerFactory.GetConfigurationHandler<Configuration>("ClanTagRankCommands");
if (_configurationHandler.Configuration() == null)
{
_configurationHandler.Set((Configuration)new Configuration().Generate());
_configurationHandler.Save();
}
Config = _configurationHandler.Configuration();
Name = "SetRank";
Description = "set a user's clan tag Rank (does not give permissions)";
Alias = "sr";
@ -56,8 +69,9 @@ namespace ClanTagRankApi.Commands
rank_player_var = await _metaService.GetPersistentMeta(rank, E.Target);
if(rank_player_var.Value == "none" || rank_player_var.Value == "None" || rank_player_var.Value == "NONE")
{
//E.Origin.Tell(E.Target.Name + "'s rank has been reset");
rank_string = E.Target.Level.ClanTag();
rank_string = E.Target.Level.ClanTag(Config);
E.Origin.Tell(E.Target.Name + "'s rank has been reset to: " + rank_string);
}