Created
August 19, 2020 01:50
-
-
Save Decad/d5c4c4722046de10553c23a793825dbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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