Merge branch 'general-devel' into patch-7
This commit is contained in:
commit
c86a0f2929
5 changed files with 115 additions and 5 deletions
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
|
|
@ -1,3 +1,2 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
custom: https://www.givedirectly.org/
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
|||
* `-worldselectpath` is identical to the old `-worldpath`. If you specify `-worldselectpath` and `-world` without specifying an absolute path the server will crash for sure.
|
||||
* Thank you again to @fjfnaranjo for supplying a [detailed feature request](https://github.com/Pryaxis/TShock/issues/1914) explaining precisely why this option should be available. Without this, we would have had no context as to why this feature was useful or important. Thank you, @fjfnaranjo!
|
||||
* This change was implemented by (@QuiCM, @hakusaro).
|
||||
* Fixed kick on hardcore death / kick on mediumcore death / ban on either from taking action against journey mode players. (@hakusaro)
|
||||
* Attempted to fix the problem with the magic mirror spawn problems. You should be able to remove your spawn point in SSC by right clicking on a bed now. (@hakusaro, @AxeelAnder)
|
||||
* Add HandleFoodPlatterTryPlacing event, which is called whenever a player places a food in a plate. Add antihack to bouncer, to prevent removing food from plates if the region is protected; To prevent placement if they are not in range; To prevent placement if the item is not placed from player hand. (@Patrikkk)
|
||||
|
||||
## TShock 4.4.0 (Pre-release 8)
|
||||
* Update for OTAPI 2.0.0.36 and Terraria 1.4.0.4. (@hakusaro, @Patrikkk, @DeathCradle)
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ namespace TShockAPI
|
|||
GetDataHandlers.MassWireOperation += OnMassWireOperation;
|
||||
GetDataHandlers.PlayerDamage += OnPlayerDamage;
|
||||
GetDataHandlers.KillMe += OnKillMe;
|
||||
GetDataHandlers.FoodPlatterTryPlacing += OnFoodPlatterTryPlacing;
|
||||
}
|
||||
|
||||
internal void OnGetSection(object sender, GetDataHandlers.GetSectionEventArgs args)
|
||||
|
|
@ -2062,6 +2063,54 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a player is trying to place an item into a food plate.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
|
||||
{
|
||||
if (args.Player.ItemInHand.type != args.ItemID)
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
if (args.Player.IsBeingDisabled())
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected disabled from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.HasBuildPermission(args.TileX, args.TileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected permissions from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Player.IsInRange(args.TileX, args.TileY))
|
||||
{
|
||||
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected range checks from {0}", args.Player.Name);
|
||||
Item item = new Item();
|
||||
item.netDefaults(args.ItemID);
|
||||
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
|
||||
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnSecondUpdate()
|
||||
{
|
||||
Task.Run(() =>
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ namespace TShockAPI
|
|||
{ PacketTypes.ToggleParty, HandleToggleParty },
|
||||
{ PacketTypes.CrystalInvasionStart, HandleOldOnesArmy },
|
||||
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
|
||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 }
|
||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
|
||||
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1863,6 +1864,52 @@ namespace TShockAPI
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
public class FoodPlatterTryPlacingEventArgs : GetDataHandledEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The X tile position of the placement action.
|
||||
/// </summary>
|
||||
public short TileX { get; set; }
|
||||
/// <summary>
|
||||
/// The Y tile position of the placement action.
|
||||
/// </summary>
|
||||
public short TileY { get; set; }
|
||||
/// <summary>
|
||||
/// The Item ID that is being placed in the plate.
|
||||
/// </summary>
|
||||
public short ItemID { get; set; }
|
||||
/// <summary>
|
||||
/// The prefix of the item that is being placed in the plate.
|
||||
/// </summary>
|
||||
public byte Prefix { get; set; }
|
||||
/// <summary>
|
||||
/// The stack of the item that is being placed in the plate.
|
||||
/// </summary>
|
||||
public short Stack { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when a player is placing an item in a food plate.
|
||||
/// </summary>
|
||||
public static HandlerList<FoodPlatterTryPlacingEventArgs> FoodPlatterTryPlacing = new HandlerList<FoodPlatterTryPlacingEventArgs>();
|
||||
private static bool OnFoodPlatterTryPlacing(TSPlayer player, MemoryStream data, short tileX, short tileY, short itemID, byte prefix, short stack)
|
||||
{
|
||||
if (FoodPlatterTryPlacing == null)
|
||||
return false;
|
||||
|
||||
var args = new FoodPlatterTryPlacingEventArgs
|
||||
{
|
||||
Player = player,
|
||||
Data = data,
|
||||
TileX = tileX,
|
||||
TileY = tileY,
|
||||
ItemID = itemID,
|
||||
Prefix = prefix,
|
||||
Stack = stack,
|
||||
};
|
||||
FoodPlatterTryPlacing.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static bool HandlePlayerInfo(GetDataHandlerArgs args)
|
||||
|
|
@ -2118,7 +2165,7 @@ namespace TShockAPI
|
|||
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpawn force teleport 'vanilla spawn' {0}", args.Player.Name);
|
||||
}
|
||||
|
||||
if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
||||
else if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
|
||||
{
|
||||
|
||||
args.Player.sX = args.TPlayer.SpawnX;
|
||||
|
|
@ -3524,7 +3571,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
// Handle kicks/bans on mediumcore/hardcore deaths.
|
||||
if (args.TPlayer.difficulty != 0) // Player is not softcore
|
||||
if (args.TPlayer.difficulty == 1 || args.TPlayer.difficulty == 2) // Player is not softcore
|
||||
{
|
||||
bool mediumcore = args.TPlayer.difficulty == 1;
|
||||
bool shouldBan = mediumcore ? TShock.Config.BanOnMediumcoreDeath : TShock.Config.BanOnHardcoreDeath;
|
||||
|
|
@ -3559,7 +3606,19 @@ namespace TShockAPI
|
|||
|
||||
return false;
|
||||
}
|
||||
private static bool HandleFoodPlatterTryPlacing(GetDataHandlerArgs args)
|
||||
{
|
||||
short tileX = args.Data.ReadInt16();
|
||||
short tileY = args.Data.ReadInt16();
|
||||
short itemID = args.Data.ReadInt16();
|
||||
byte prefix = args.Data.ReadInt8();
|
||||
short stack = args.Data.ReadInt16();
|
||||
|
||||
if (OnFoodPlatterTryPlacing(args.Player, args.Data, tileX, tileY, itemID, prefix, stack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum EditAction
|
||||
{
|
||||
|
|
|
|||
|
|
@ -221,4 +221,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue