Skip to content
Permalink
Browse files

Minor refactorings

  • Loading branch information
Trojaner committed Mar 11, 2019
1 parent e614fb8 commit 963f03192ebc5c3cae1689039a3b05a6262a6b43
@@ -24,19 +24,19 @@ public abstract class Plugin<TConfig> : Plugin where TConfig : class, new()

public override object DefaultConfiguration => new TConfig();

public override async Task SaveConfiguration()
public override async Task SaveConfigurationAsync()
{
await base.SaveConfiguration();
await base.SaveConfigurationAsync();
if (Configuration != null)
{
Configuration.Set(ConfigurationInstance);
await Configuration.SaveAsync();
}
}

public override async Task LoadConfiguration()
public override async Task LoadConfigurationAsync()
{
await base.LoadConfiguration();
await base.LoadConfigurationAsync();
if (Configuration == null)
return;

@@ -85,7 +85,7 @@ protected Plugin(string name, IDependencyContainer container)
Container.RegisterSingletonType<ILogger, PluginLogger>("plugin_logger");
}

public virtual async Task SaveConfiguration()
public virtual async Task SaveConfigurationAsync()
{
if (Configuration != null)
await Configuration.SaveAsync();
@@ -135,7 +135,7 @@ public async Task<bool> ActivateAsync(bool isReload)
return false;
}

await LoadConfiguration();
await LoadConfigurationAsync();

if (DefaultTranslations != null)
{
@@ -165,7 +165,7 @@ public async Task<bool> ActivateAsync(bool isReload)
return true;
}

public virtual async Task LoadConfiguration()
public virtual async Task LoadConfigurationAsync()
{
if (DefaultConfiguration != null)
{
@@ -214,7 +214,7 @@ public async Task<bool> DeactivateAsync()
public ITranslationCollection Translations { get; protected set; }
public virtual Dictionary<string, string> DefaultTranslations => null;

public void RegisterCommandsFromObject(object o)
public void RegisterCommands(object o)
{
ClrPluginLoader p = PluginLoader as ClrPluginLoader;
p?.RegisterCommands(this, o);
@@ -34,7 +34,7 @@ public async Task KillPlayer(IUser sender, IPlayer target)
[CommandUser(typeof(IConsole))] // only console can call it
public async Task Broadcast(IUser sender, string[] args)
{
await userManager.BroadcastAsync(sender, translations.GetAsync("broadcast", sender, string.Join(" ", args)).Result);
await userManager.BroadcastAsync(sender, await translations.GetAsync("broadcast", sender, string.Join(" ", args)));
}
}
}
@@ -24,8 +24,8 @@ public class CommandsPlugin : Plugin

protected override async Task OnActivate(bool isFromReload)
{
CommandsCollection commandsObject = new CommandsCollection(userManager, Translations);
RegisterCommandsFromObject(commandsObject);
CommandsCollection commandsCollection = new CommandsCollection(userManager, Translations);
RegisterCommands(commandsCollection);
}
}
}
@@ -10,7 +10,6 @@ public class HelloWorldPlugin : Plugin
{
public HelloWorldPlugin(IDependencyContainer container) : base("Hello World Plugin", container)
{
RegisterCommandsFromObject(this);
}

public override object DefaultConfiguration => new

0 comments on commit 963f031

Please sign in to comment.
You can’t perform that action at this time.