ExamplePlugin.cs
using Example.Commands;
using Rocket.Core;
using Rocket.Core.Plugins;
namespace Example
{
public class ExamplePlugin : RocketPlugin<ExampleConfiguration>
{
protected override void Load()
{
if (Configuration.Instance.MuteEnabled)
{
// injecting ExamplePlugin instance 'this'
var cmd = new MuteCommand(this);
// manually registering IRocketCommand
R.Commands.Register(cmd);
}
}
}
}
ExampleConfiguration.cs
using Rocket.API;
namespace Example
{
public class ExampleConfiguration : IRocketPluginConfiguration
{
public bool MuteEnabled { get; set; }
public string MuteCommandName { get; set; }
public void LoadDefaults()
{
MuteEnabled = true;
MuteCommandName = "mute";
}
}
}
Commands/MuteCommand.cs
using Rocket.API;
using System.Collections.Generic;
namespace Example.Commands
{
public class MuteCommand : IRocketCommand
{
private readonly ExamplePlugin pluginInstance;
// Constructor blocks rocket automatically registering IRocketCommand
public MuteCommand(ExamplePlugin pluginInstance)
{
this.pluginInstance = pluginInstance;
}
public AllowedCaller AllowedCaller => AllowedCaller.Both;
// using MuteCommandName from configuration
public string Name => pluginInstance.Configuration.Instance.MuteCommandName;
public string Help => string.Empty;
public string Syntax => string.Empty;
public List<string> Aliases => new List<string>();
public List<string> Permissions => new List<string>();
public void Execute(IRocketPlayer caller, string[] command)
{
// Your execute code here obviously
}
}
}