Skip to content

Instantly share code, notes, and snippets.

@Decad
Created August 19, 2020 01:50
Show Gist options
  • Save Decad/d5c4c4722046de10553c23a793825dbd to your computer and use it in GitHub Desktop.
Save Decad/d5c4c4722046de10553c23a793825dbd to your computer and use it in GitHub Desktop.
In your all your plugins you extend QuirkPlugin now not CSharpPlugi.
Then you can put `[ChatCommand("auth")]` style attributes on your chat commands rather than register them
public abstract class QuirkPlugin : CSharpPlugin
{
protected Command cmd = Interface.Oxide.GetLibrary<Command>();
public override void HandleAddedToManager(PluginManager manager)
{
foreach (MethodInfo method in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance))
{
object[] attributes = method.GetCustomAttributes(typeof(ChatCommandAttribute), true);
if (attributes.Length > 0)
{
if (attributes[0] is ChatCommandAttribute attribute)
{
cmd.AddChatCommand(attribute.Command, this, method.Name);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment