From e37ada8749bd6a2f3c6c338dc8dd2c7421ea23e6 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Sun, 21 Apr 2013 19:26:17 -0400 Subject: [PATCH] Added event for reloading configs, so when a user does /reload it informs plugins that a config reload is requested. --- TShockAPI/Commands.cs | 3 ++- TShockAPI/Hooks/GeneralHooks.cs | 30 ++++++++++++++++++++++++++++++ TShockAPI/TShockAPI.csproj | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 TShockAPI/Hooks/GeneralHooks.cs diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 648b357b..b1b3db61 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -2288,10 +2288,11 @@ namespace TShockAPI FileTools.SetupConfig(); TShock.HandleCommandLinePostConfigLoad(Environment.GetCommandLineArgs()); TShock.Groups.LoadPermisions(); - //todo: Create an event for reloads to propegate to plugins. TShock.Regions.ReloadAllRegions(); args.Player.SendSuccessMessage( "Configuration, permissions, and regions reload complete. Some changes may require a server restart."); + + Hooks.GeneralHooks.OnReloadEvent(args.Player); } private static void ServerPassword(CommandArgs args) diff --git a/TShockAPI/Hooks/GeneralHooks.cs b/TShockAPI/Hooks/GeneralHooks.cs new file mode 100644 index 00000000..d01ded4c --- /dev/null +++ b/TShockAPI/Hooks/GeneralHooks.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TShockAPI.Hooks +{ + public class ReloadEventArgs + { + public TSPlayer Player { get; set; } + public ReloadEventArgs(TSPlayer ply) + { + Player = ply; + } + } + + public class GeneralHooks + { + public delegate void ReloadEventD(ReloadEventArgs e); + public static event ReloadEventD ReloadEvent; + + public static void OnReloadEvent(TSPlayer ply) + { + if(ReloadEvent == null) + return; + + ReloadEvent(new ReloadEventArgs(ply)); + } + } +} diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index beed07b1..697474e2 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -83,6 +83,7 @@ + @@ -186,7 +187,7 @@ - +