Merge pull request #1268 from ProfessorXZ/general-devel

Fixes #1250
This commit is contained in:
Rodrigo 2016-08-06 21:14:24 +01:00 committed by GitHub
commit 6b0b67f1ca
3 changed files with 46 additions and 6 deletions

View file

@ -5,6 +5,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming Changes
* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ)
* API: Added ItemForceIntoChest hook (@WhiteXZ)
* The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju)
* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ)
* Fixed clients being able to remove other players' portals (@ProfessorXZ)
@ -14,6 +15,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Fixed a bug involving Item Frames which allowed players to duplicate items (@ProfessorXZ)
* Fixed an issue allowing clients to teleport NPCs to arbitrary locations (@ProfessorXZ)
* Fixed a bug where players would get teleported to their previous location after dismounting the Unicorn Mount (@ProfessorXZ)
* Players can no longer quick stack items into region protected chests (@ProfessorXZ)
## TShock 4.3.17

View file

@ -759,7 +759,7 @@ namespace TShockAPI.DB
return false;
}
return AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
return ply.HasPermission(Permissions.editregion) || AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
}
/// <summary>

View file

@ -45,7 +45,7 @@ namespace TShockAPI
/// This is the TShock main class. TShock is a plugin on the TerrariaServerAPI, so it extends the base TerrariaPlugin.
/// TShock also complies with the API versioning system, and defines its required API version here.
/// </summary>
[ApiVersion(1, 23)]
[ApiVersion(1, 24)]
public class TShock : TerrariaPlugin
{
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
@ -317,6 +317,7 @@ namespace TShockAPI
ServerApi.Hooks.WorldChristmasCheck.Register(this, OnXmasCheck);
ServerApi.Hooks.WorldHalloweenCheck.Register(this, OnHalloweenCheck);
ServerApi.Hooks.NetNameCollision.Register(this, NetHooks_NameCollision);
ServerApi.Hooks.ItemForceIntoChest.Register(this, OnItemForceIntoChest);
Hooks.PlayerHooks.PlayerPreLogin += OnPlayerPreLogin;
Hooks.PlayerHooks.PlayerPostLogin += OnPlayerLogin;
Hooks.AccountHooks.AccountDelete += OnAccountDelete;
@ -384,6 +385,7 @@ namespace TShockAPI
ServerApi.Hooks.WorldChristmasCheck.Deregister(this, OnXmasCheck);
ServerApi.Hooks.WorldHalloweenCheck.Deregister(this, OnHalloweenCheck);
ServerApi.Hooks.NetNameCollision.Deregister(this, NetHooks_NameCollision);
ServerApi.Hooks.ItemForceIntoChest.Deregister(this, OnItemForceIntoChest);
TShockAPI.Hooks.PlayerHooks.PlayerPostLogin -= OnPlayerLogin;
if (File.Exists(Path.Combine(SavePath, "tshock.pid")))
@ -471,6 +473,44 @@ namespace TShockAPI
}
}
/// <summary>OnItemForceIntoChest - Internal hook fired when a player quick stacks items into a chest.</summary>
/// <param name="args">The <see cref="ForceItemIntoChestEventArgs"/> object.</param>
private void OnItemForceIntoChest(ForceItemIntoChestEventArgs args)
{
if (args.Handled)
{
return;
}
if (args.Player == null)
{
args.Handled = true;
return;
}
TSPlayer tsplr = Players[args.Player.whoAmI];
if (tsplr == null)
{
args.Handled = true;
return;
}
if (args.Chest != null)
{
if (Config.RegionProtectChests && !Regions.CanBuild((int)args.Position.X, (int)args.Position.Y, tsplr))
{
args.Handled = true;
return;
}
if (CheckRangePermission(tsplr, (int)args.Position.X, (int)args.Position.Y))
{
args.Handled = true;
return;
}
}
}
/// <summary>OnXmasCheck - Internal hook fired when the XMasCheck happens.</summary>
/// <param name="args">args - The ChristmasCheckEventArgs object.</param>
private void OnXmasCheck(ChristmasCheckEventArgs args)
@ -1700,8 +1740,7 @@ namespace TShockAPI
return true;
}
if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
Regions.InArea(tileX, tileY))
if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{
@ -1768,8 +1807,7 @@ namespace TShockAPI
return true;
}
if (!player.HasPermission(Permissions.editregion) && !Regions.CanBuild(tileX, tileY, player) &&
Regions.InArea(tileX, tileY))
if (!Regions.CanBuild(tileX, tileY, player))
{
if (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - player.RPm) > 2000)
{