@@ -52,6 +52,7 @@ public class ProtectorPlugin: TerrariaPlugin, IDisposable {
5252 protected PluginInfo PluginInfo { get ; private set ; }
5353 protected Configuration Config { get ; private set ; }
5454 protected GetDataHookHandler GetDataHookHandler { get ; private set ; }
55+ protected GetDataHookHandler GetDataHookHandlerLate { get ; private set ; }
5556 public ChestManager ChestManager { get ; private set ; }
5657 public ProtectionManager ProtectionManager { get ; private set ; }
5758 protected UserInteractionHandler UserInteractionHandler { get ; private set ; }
@@ -208,10 +209,9 @@ private void AddHooks() {
208209 if ( this . GetDataHookHandler != null )
209210 throw new InvalidOperationException ( "Hooks already registered." ) ;
210211
212+ // this hook should ideally be registered BEFORE all other plugins
211213 this . GetDataHookHandler = new GetDataHookHandler ( this , true ) ;
212- this . GetDataHookHandler . InvokeTileOnObjectPlacement = false ;
213214 this . GetDataHookHandler . TileEdit += this . Net_TileEdit ;
214- this . GetDataHookHandler . ObjectPlacement += this . Net_ObjectPlacement ;
215215 this . GetDataHookHandler . SignEdit += this . Net_SignEdit ;
216216 this . GetDataHookHandler . SignRead += this . Net_SignRead ;
217217 this . GetDataHookHandler . ChestPlace += this . Net_ChestPlace ;
@@ -224,6 +224,11 @@ private void AddHooks() {
224224 this . GetDataHookHandler . DoorUse += this . Net_DoorUse ;
225225 this . GetDataHookHandler . QuickStackNearby += this . Net_QuickStackNearby ;
226226
227+ // this hook should ideally be registered AFTER all other plugins
228+ this . GetDataHookHandlerLate = new GetDataHookHandler ( this , true , - 100 ) ;
229+ this . GetDataHookHandlerLate . TileEdit += this . Net_TileEditLate ;
230+ this . GetDataHookHandlerLate . ObjectPlacement += this . Net_ObjectPlacement ;
231+
227232 ServerApi . Hooks . GameUpdate . Register ( this , this . Game_Update ) ;
228233 ServerApi . Hooks . WorldSave . Register ( this , this . World_SaveWorld ) ;
229234 GetDataHandlers . PlayerSpawn += this . TShock_PlayerSpawn ;
@@ -245,6 +250,13 @@ private void Net_TileEdit(object sender, TileEditEventArgs e) {
245250 e . Handled = this . UserInteractionHandler . HandleTileEdit ( e . Player , e . EditType , e . BlockType , e . Location , e . ObjectStyle ) ;
246251 }
247252
253+ private void Net_TileEditLate ( object sender , TileEditEventArgs e ) {
254+ if ( this . isDisposed || ! this . hooksEnabled || e . Handled )
255+ return ;
256+
257+ e . Handled = this . UserInteractionHandler . HandleTileEdit ( e . Player , e . EditType , e . BlockType , e . Location , e . ObjectStyle , true ) ;
258+ }
259+
248260 private void Net_ObjectPlacement ( object sender , ObjectPlacementEventArgs e ) {
249261 if ( this . isDisposed || ! this . hooksEnabled || e . Handled )
250262 return ;
0 commit comments