From 072ed2aa651ea51970e851afc521d714525d8069 Mon Sep 17 00:00:00 2001 From: courtney Date: Sat, 10 Mar 2018 21:22:24 +0800 Subject: [PATCH] Updated to working example --- ExamplePlugin/ExamplePlugin/ExamplePlugin.cs | 7 +++---- ExamplePlugin/ExamplePlugin/HelloWorldCommand.cs | 5 ++--- .../ExamplePlugin/RoundStartEventHandler.cs | 16 +++++++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ExamplePlugin/ExamplePlugin/ExamplePlugin.cs b/ExamplePlugin/ExamplePlugin/ExamplePlugin.cs index 36e4053a..a4294681 100644 --- a/ExamplePlugin/ExamplePlugin/ExamplePlugin.cs +++ b/ExamplePlugin/ExamplePlugin/ExamplePlugin.cs @@ -1,5 +1,4 @@ -using System; -using Smod.TestPlugin; +using Smod.TestPlugin; using Smod2; using Smod2.Attributes; using Smod2.Events; @@ -24,13 +23,13 @@ public override void OnDisable() public override void OnEnable() { - Console.WriteLine("On enable :)"); + this.Info("Example Plugin has loaded :)"); } public override void Register() { // Register Events - this.AddEventHandler(typeof(IEventRoundStart), new RoundStartEventHandler(), Priority.Highest); + this.AddEventHandler(typeof(IEventRoundStart), new RoundStartHandler(this), Priority.Highest); // Register Commands this.AddCommand("hello", new HelloWorldCommand(this)); } diff --git a/ExamplePlugin/ExamplePlugin/HelloWorldCommand.cs b/ExamplePlugin/ExamplePlugin/HelloWorldCommand.cs index 593a5a27..8de4908a 100644 --- a/ExamplePlugin/ExamplePlugin/HelloWorldCommand.cs +++ b/ExamplePlugin/ExamplePlugin/HelloWorldCommand.cs @@ -1,5 +1,4 @@ - -using Smod2.Commands; +using Smod2.Commands; namespace ExamplePlugin { @@ -21,7 +20,7 @@ public string GetUsage() return ""; } - public void OnCall(string[] args) + public void OnCall(ICommandManager manger, string[] args) { plugin.Info("Hello world!"); } diff --git a/ExamplePlugin/ExamplePlugin/RoundStartEventHandler.cs b/ExamplePlugin/ExamplePlugin/RoundStartEventHandler.cs index aaed6519..05a4b98e 100644 --- a/ExamplePlugin/ExamplePlugin/RoundStartEventHandler.cs +++ b/ExamplePlugin/ExamplePlugin/RoundStartEventHandler.cs @@ -1,15 +1,21 @@ -using System; -using Smod2; +using Smod2; +using Smod2.API; using Smod2.Events; -using Smod2.Game; namespace Smod.TestPlugin { - class RoundStartEventHandler: IEventRoundStart + class RoundStartHandler : IEventRoundStart { + private Plugin plugin; + + public RoundStartHandler(Plugin plugin) + { + this.plugin = plugin; + } + public void OnRoundStart(Server server) { - server.MaxPlayers = 2 ^ 32; + plugin.Info("ROUND START EVENT CALLER"); } } }