Merge pull request #3116 from ACaiCat/general-devel
fix(Bouncer): fix players bypass region protection and build permissions when using Quick Stack
This commit is contained in:
commit
108c856fd1
1 changed files with 34 additions and 2 deletions
|
|
@ -19,7 +19,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Terraria.ID;
|
using Terraria.ID;
|
||||||
using TShockAPI.Net;
|
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using TShockAPI.Localization;
|
using TShockAPI.Localization;
|
||||||
|
|
@ -29,6 +28,7 @@ using Terraria.DataStructures;
|
||||||
using Terraria.Localization;
|
using Terraria.Localization;
|
||||||
using TShockAPI.Models.PlayerUpdate;
|
using TShockAPI.Models.PlayerUpdate;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using OTAPI;
|
||||||
using Terraria.GameContent.Tile_Entities;
|
using Terraria.GameContent.Tile_Entities;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
|
|
@ -137,6 +137,7 @@ namespace TShockAPI
|
||||||
GetDataHandlers.KillMe += OnKillMe;
|
GetDataHandlers.KillMe += OnKillMe;
|
||||||
GetDataHandlers.FishOutNPC += OnFishOutNPC;
|
GetDataHandlers.FishOutNPC += OnFishOutNPC;
|
||||||
GetDataHandlers.FoodPlatterTryPlacing += OnFoodPlatterTryPlacing;
|
GetDataHandlers.FoodPlatterTryPlacing += OnFoodPlatterTryPlacing;
|
||||||
|
OTAPI.Hooks.Chest.QuickStack += OnQuickStack;
|
||||||
|
|
||||||
|
|
||||||
// The following section is based off Player.PlaceThing_Tiles_PlaceIt and Player.PlaceThing_Tiles_PlaceIt_GetLegacyTileStyle.
|
// The following section is based off Player.PlaceThing_Tiles_PlaceIt and Player.PlaceThing_Tiles_PlaceIt_GetLegacyTileStyle.
|
||||||
|
|
@ -2900,6 +2901,37 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a player is trying to put an item into chest through Quick Stack.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
internal void OnQuickStack(object sender, OTAPI.Hooks.Chest.QuickStackEventArgs args)
|
||||||
|
{
|
||||||
|
var id = args.ChestIndex;
|
||||||
|
var plr = TShock.Players[args.PlayerId];
|
||||||
|
|
||||||
|
if (plr is not { Active: true })
|
||||||
|
{
|
||||||
|
args.Result = HookResult.Cancel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plr.IsBeingDisabled())
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug(GetString("Bouncer / OnQuickStack rejected from disable from {0}", plr.Name));
|
||||||
|
args.Result = HookResult.Cancel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plr.HasBuildPermission(Main.chest[id].x, Main.chest[id].y) && TShock.Config.Settings.RegionProtectChests)
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug(GetString("Bouncer / OnQuickStack rejected from region protection? from {0}", plr.Name));
|
||||||
|
args.Result = HookResult.Cancel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void OnSecondUpdate()
|
internal void OnSecondUpdate()
|
||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue