From ed75e1548e5c0c26998a7fda66f23695cb7e106b Mon Sep 17 00:00:00 2001 From: CoderCow Date: Sun, 4 Jun 2017 16:20:10 +0200 Subject: [PATCH] fix(/tradechest): make command work again --- Implementation/PluginCooperationHandler.cs | 5 +++-- Implementation/ProtectorPlugin.cs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Implementation/PluginCooperationHandler.cs b/Implementation/PluginCooperationHandler.cs index ec4dca1..0cae868 100644 --- a/Implementation/PluginCooperationHandler.cs +++ b/Implementation/PluginCooperationHandler.cs @@ -29,14 +29,13 @@ private enum InfiniteChestsChestFlags { public PluginTrace PluginTrace { get; } public Configuration Config { get; private set; } - public ChestManager ChestManager { get; private set; } + public ChestManager ChestManager { get; set; } public bool IsSeconomyAvailable { get; private set; } public PluginCooperationHandler(PluginTrace pluginTrace, Configuration config, ChestManager chestManager) { Contract.Requires(pluginTrace != null); Contract.Requires(config != null); - Contract.Requires(chestManager != null); this.PluginTrace = pluginTrace; this.Config = config; @@ -49,6 +48,8 @@ public PluginCooperationHandler(PluginTrace pluginTrace, Configuration config, C public void InfiniteChests_ChestDataImport( ChestManager chestManager, ProtectionManager protectionManager, out int importedChests, out int protectFailures ) { + Contract.Assert(this.ChestManager != null); + importedChests = 0; protectFailures = 0; diff --git a/Implementation/ProtectorPlugin.cs b/Implementation/ProtectorPlugin.cs index 8495947..c94f505 100644 --- a/Implementation/ProtectorPlugin.cs +++ b/Implementation/ProtectorPlugin.cs @@ -101,12 +101,13 @@ private void Game_PostInitialize(EventArgs e) { if (!this.InitWorldMetdataHandler()) return; + this.PluginCooperationHandler = new PluginCooperationHandler(this.Trace, this.Config, this.ChestManager); this.ChestManager = new ChestManager( this.Trace, this.Config, this.ServerMetadataHandler, this.WorldMetadata, this.PluginCooperationHandler); this.ProtectionManager = new ProtectionManager( this.Trace, this.Config, this.ChestManager, this.ServerMetadataHandler, this.WorldMetadata); - this.PluginCooperationHandler = new PluginCooperationHandler(this.Trace, this.Config, this.ChestManager); + this.PluginCooperationHandler.ChestManager = this.ChestManager; this.InitUserInteractionHandler(); this.UserInteractionHandler.EnsureProtectionData(TSPlayer.Server); @@ -209,7 +210,7 @@ private void AddHooks() { if (this.GetDataHookHandler != null) throw new InvalidOperationException("Hooks already registered."); - // this hook should ideally be registered BEFORE all other plugins + // this handler should ideally be registered BEFORE all other plugins this.GetDataHookHandler = new GetDataHookHandler(this, true); this.GetDataHookHandler.TileEdit += this.Net_TileEdit; this.GetDataHookHandler.SignEdit += this.Net_SignEdit; @@ -224,7 +225,7 @@ private void AddHooks() { this.GetDataHookHandler.DoorUse += this.Net_DoorUse; this.GetDataHookHandler.QuickStackNearby += this.Net_QuickStackNearby; - // this hook should ideally be registered AFTER all other plugins + // this handler should ideally be registered AFTER all other plugins this.GetDataHookHandlerLate = new GetDataHookHandler(this, true, -100); this.GetDataHookHandlerLate.TileEdit += this.Net_TileEditLate; this.GetDataHookHandlerLate.ObjectPlacement += this.Net_ObjectPlacement;