Merge branch 'general-devel' into fix-invalid-groups

This commit is contained in:
quake1337 2021-07-31 16:38:12 +02:00 committed by GitHub
commit 91376ae087
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 128 additions and 81 deletions

View file

@ -260,6 +260,13 @@ namespace TShockAPI
try
{
if (!TShock.Utils.TilePlacementValid(tileX, tileY))
{
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0} {1} {2}", args.Player.Name, action, editData);
args.Handled = true;
return;
}
if (editData < 0 ||
((action == EditAction.PlaceTile || action == EditAction.ReplaceTile) && editData >= Main.maxTileSets) ||
((action == EditAction.PlaceWall || action == EditAction.ReplaceWall) && editData >= Main.maxWallTypes))
@ -270,14 +277,6 @@ namespace TShockAPI
return;
}
if (!TShock.Utils.TilePlacementValid(tileX, tileY))
{
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit rejected from (tile placement valid) {0} {1} {2}", args.Player.Name, action, editData);
args.Player.SendTileSquare(tileX, tileY, 1);
args.Handled = true;
return;
}
if (action == EditAction.KillTile && Main.tile[tileX, tileY].type == TileID.MagicalIceBlock)
{
TShock.Log.ConsoleDebug("Bouncer / OnTileEdit super accepted from (ice block) {0} {1} {2}", args.Player.Name, action, editData);
@ -1654,6 +1653,13 @@ namespace TShockAPI
short type = args.Type;
short style = args.Style;
if (!TShock.Utils.TilePlacementValid(x, y))
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected valid placements from {0}", args.Player.Name);
args.Handled = true;
return;
}
if (type < 0 || type >= Main.maxTileSets)
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected out of bounds tile from {0}", args.Player.Name);
@ -1702,14 +1708,6 @@ namespace TShockAPI
return;
}
if (!TShock.Utils.TilePlacementValid(x, y))
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected valid placements from {0}", args.Player.Name);
args.Player.SendTileSquare(x, y, 1);
args.Handled = true;
return;
}
if (args.Player.Dead && TShock.Config.Settings.PreventDeadModification)
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceObject rejected dead people don't do things from {0}", args.Player.Name);
@ -1726,7 +1724,7 @@ namespace TShockAPI
return;
}
// This is neccessary to check in order to prevent special tiles such as
// This is necessary to check in order to prevent special tiles such as
// queen bee larva, paintings etc that use this packet from being placed
// without selecting the right item.
if (type != args.Player.TPlayer.inventory[args.Player.TPlayer.selectedItem].createTile)
@ -1801,6 +1799,13 @@ namespace TShockAPI
/// <param name="args">The packet arguments that the event has.</param>
internal void OnPlaceTileEntity(object sender, GetDataHandlers.PlaceTileEntityEventArgs args)
{
if (!TShock.Utils.TilePlacementValid(args.X, args.Y))
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected tile placement valid from {0}", args.Player.Name);
args.Handled = true;
return;
}
if (args.Player.IsBeingDisabled())
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceTileEntity rejected disabled from {0}", args.Player.Name);
@ -1828,6 +1833,13 @@ namespace TShockAPI
/// <param name="args">The packet arguments that the event has.</param>
internal void OnPlaceItemFrame(object sender, GetDataHandlers.PlaceItemFrameEventArgs args)
{
if (!TShock.Utils.TilePlacementValid(args.X, args.Y))
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected tile placement valid from {0}", args.Player.Name);
args.Handled = true;
return;
}
if (args.Player.IsBeingDisabled())
{
TShock.Log.ConsoleDebug("Bouncer / OnPlaceItemFrame rejected disabled from {0}", args.Player.Name);
@ -2129,6 +2141,13 @@ namespace TShockAPI
/// <param name="args"></param>
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
{
if (!TShock.Utils.TilePlacementValid(args.TileX, args.TileY))
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected tile placement valid from {0}", args.Player.Name);
args.Handled = true;
return;
}
if ((args.Player.SelectedItem.type != args.ItemID && args.Player.ItemInHand.type != args.ItemID))
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);

View file

@ -50,7 +50,7 @@ namespace TShockAPI
public bool Silent { get; private set; }
/// <summary>
/// Parameters passed to the arguement. Does not include the command name.
/// Parameters passed to the argument. Does not include the command name.
/// IE '/kick "jerk face"' will only have 1 argument
/// </summary>
public List<string> Parameters { get; private set; }
@ -945,7 +945,7 @@ namespace TShockAPI
}
catch (UserAccountManagerException ex)
{
args.Player.SendErrorMessage("Sorry, an error occured: " + ex.Message + ".");
args.Player.SendErrorMessage("Sorry, an error occurred: " + ex.Message + ".");
TShock.Log.ConsoleError("PasswordUser returned an error: " + ex);
}
}
@ -1009,7 +1009,7 @@ namespace TShockAPI
}
catch (UserAccountManagerException ex)
{
args.Player.SendErrorMessage("Sorry, an error occured: " + ex.Message + ".");
args.Player.SendErrorMessage("Sorry, an error occurred: " + ex.Message + ".");
TShock.Log.ConsoleError("RegisterUser returned an error: " + ex);
}
}
@ -1222,7 +1222,7 @@ namespace TShockAPI
if (DateTime.TryParse(account.LastAccessed, out LastSeen))
{
LastSeen = DateTime.Parse(account.LastAccessed).ToLocalTime();
args.Player.SendSuccessMessage("{0}'s last login occured {1} {2} UTC{3}.", account.Name, LastSeen.ToShortDateString(),
args.Player.SendSuccessMessage("{0}'s last login occurred {1} {2} UTC{3}.", account.Name, LastSeen.ToShortDateString(),
LastSeen.ToShortTimeString(), Timezone);
}
@ -5524,7 +5524,7 @@ namespace TShockAPI
#endregion General Commands
#region Cheat Commands
#region Game Commands
private static void Clear(CommandArgs args)
{
@ -6478,6 +6478,6 @@ namespace TShockAPI
}
}
#endregion Cheat Comamnds
#endregion Game Commands
}
}

View file

@ -464,14 +464,14 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
TShock.Log.Error($"An exception has occured during database transaction: {ex.Message}");
TShock.Log.Error($"An exception has occurred during database transaction: {ex.Message}");
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
TShock.Log.Error($"An exception has occured during database rollback: {rollbackEx.Message}");
TShock.Log.Error($"An exception has occurred during database rollback: {rollbackEx.Message}");
}
}
}

View file

@ -168,7 +168,7 @@ namespace TShockAPI.DB
}
/// <summary>
/// Delets the region from this world with a given ID.
/// Deletes the region from this world with a given ID.
/// </summary>
/// <param name="id">The ID of the region to delete.</param>
/// <returns>Whether the region was successfully deleted.</returns>
@ -584,7 +584,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="regionName">Region name</param>
/// <param name="newOwner">New owner's username</param>
/// <returns>Whether the change was successfull</returns>
/// <returns>Whether the change was successful</returns>
public bool ChangeOwner(string regionName, string newOwner)
{
var region = GetRegionByName(regionName);
@ -604,7 +604,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="regionName">Region name</param>
/// <param name="groupName">Group's name</param>
/// <returns>Whether the change was successfull</returns>
/// <returns>Whether the change was successful</returns>
public bool AllowGroup(string regionName, string groupName)
{
string mergedGroups = "";
@ -646,7 +646,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="regionName">Region name</param>
/// <param name="group">Group name</param>
/// <returns>Whether the change was successfull</returns>
/// <returns>Whether the change was successful</returns>
public bool RemoveGroup(string regionName, string group)
{
Region r = GetRegionByName(regionName);
@ -688,7 +688,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="name">Region name</param>
/// <param name="z">New Z index</param>
/// <returns>Whether the change was successfull</returns>
/// <returns>Whether the change was successful</returns>
public bool SetZ(string name, int z)
{
try

View file

@ -56,7 +56,7 @@ namespace TShockAPI.DB
{
int checkX=reader.Get<int>("X");
int checkY=reader.Get<int>("Y");
//fix leftover inconsistancies
//fix leftover inconsistencies
if (checkX==0)
checkX++;
if (checkY==0)

View file

@ -378,7 +378,7 @@ namespace TShockAPI.DB
/// <summary>The hashed password for the user account.</summary>
public string Password { get; internal set; }
/// <summary>The user's saved Univerally Unique Identifier token.</summary>
/// <summary>The user's saved Universally Unique Identifier token.</summary>
public string UUID { get; set; }
/// <summary>The group object that the user account is a part of.</summary>

View file

@ -139,7 +139,7 @@ namespace TShockAPI.DB
/// <param name="warpName">The warp name.</param>
/// <param name="x">The X position.</param>
/// <param name="y">The Y position.</param>
/// <returns>Whether the operation suceeded.</returns>
/// <returns>Whether the operation succeeded.</returns>
public bool Position(string warpName, int x, int y)
{
try
@ -163,7 +163,7 @@ namespace TShockAPI.DB
/// </summary>
/// <param name="warpName">The warp name.</param>
/// <param name="state">The state.</param>
/// <returns>Whether the operation suceeded.</returns>
/// <returns>Whether the operation succeeded.</returns>
public bool Hide(string warpName, bool state)
{
try
@ -216,4 +216,4 @@ namespace TShockAPI.DB
IsPrivate = false;
}
}
}
}

View file

@ -29,7 +29,7 @@ namespace TShockAPI
public class FileTools
{
private const string MotdFormat =
"Welcome to [c/ffff00:%map%] on [c/7ddff8:T][c/81dbf6:S][c/86d7f4:h][c/8ad3f3:o][c/8ecef1:c][c/93caef:k] for [c/55d284:T][c/62d27a:e][c/6fd16f:r][c/7cd165:r][c/89d15a:a][c/95d150:r][c/a4d145:i][c/b1d03b:a].\n[c/FFFFFF:Online player(s):] [c/FFFF00:%players%]\nType [c/55D284:%specifier%][c/62D27A:h][c/6FD16F:e][c/7CD165:l][c/89D15A:p] for a list of commands.\n";
"Welcome to [c/ffff00:%map%] on [c/7ddff8:T][c/81dbf6:S][c/86d7f4:h][c/8ad3f3:o][c/8ecef1:c][c/93caef:k] for [c/55d284:T][c/62d27a:e][c/6fd16f:r][c/7cd165:r][c/89d15a:a][c/95d150:r][c/a4d145:i][c/b1d03b:a].\n[c/FFFFFF:Online players (%onlineplayers%/%serverslots%):] [c/FFFF00:%players%]\nType [c/55D284:%specifier%][c/62D27A:h][c/6FD16F:e][c/7CD165:l][c/89D15A:p] for a list of commands.\n";
/// <summary>
/// Path to the file containing the rules.
/// </summary>

View file

@ -346,7 +346,7 @@ namespace TShockAPI
/// </summary>
public Vector2 Velocity { get; set; }
/// <summary>
/// Original poisition of the player when using Potion of Return.
/// Original position of the player when using Potion of Return.
/// </summary>
public Vector2? OriginalPos { get; set; }
/// <summary>
@ -770,7 +770,7 @@ namespace TShockAPI
{
/// <summary>The projectile's identity...?</summary>
public int ProjectileIdentity;
/// <summary>The the player index of the projectile's owner (Main.players).</summary>
/// <summary>The player index of the projectile's owner (Main.players).</summary>
public byte ProjectileOwner;
/// <summary>The index of the projectile in Main.projectile.</summary>
public int ProjectileIndex;
@ -1846,7 +1846,7 @@ namespace TShockAPI
/// </summary>
public byte ID { get; set; }
/// <summary>
/// The direction the damage is occuring from
/// The direction the damage is occurring from
/// </summary>
public byte Direction { get; set; }
/// <summary>
@ -1902,7 +1902,7 @@ namespace TShockAPI
/// </summary>
public byte Direction { get; set; }
/// <summary>
/// Amount of damage delt
/// Amount of damage dealt
/// </summary>
public short Damage { get; set; }
/// <summary>
@ -1989,7 +1989,7 @@ namespace TShockAPI
/// </summary>
public int Slot { get; set; }
/// <summary>
/// Wether or not the slot that is being modified is a Dye slot.
/// Whether or not the slot that is being modified is a Dye slot.
/// </summary>
public bool IsDye { get; set; }
/// <summary>
@ -2812,10 +2812,26 @@ namespace TShockAPI
{
args.Player.SendErrorMessage("You do not have permission to hurt Town NPCs.");
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
TShock.Log.ConsoleDebug("GetDataHandlers / HandleNpcStrike rejected npc strike {0}", args.Player.Name);
TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected npc strike {args.Player.Name}");
return true;
}
if (Main.npc[id].netID == NPCID.EmpressButterfly)
{
if (!args.Player.HasPermission(Permissions.summonboss))
{
args.Player.SendErrorMessage("You do not have permission to summon the Empress of Light.");
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
TShock.Log.ConsoleDebug($"GetDataHandlers / HandleNpcStrike rejected EoL summon from {args.Player.Name}");
return true;
}
else if (!TShock.Config.Settings.AnonymousBossInvasions)
{
TShock.Utils.Broadcast(string.Format($"{args.Player.Name} summoned the Empress of Light!"), 175, 75, 255);
}
else
TShock.Utils.SendLogs(string.Format($"{args.Player.Name} summoned the Empress of Light!"), Color.PaleVioletRed, args.Player);
}
return false;
}
@ -3207,10 +3223,23 @@ namespace TShockAPI
return true;
}
if (type == 3 && !args.Player.HasPermission(Permissions.usesundial))
if (type == 3)
{
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSpecial rejected enchanted sundial permission {0}", args.Player.Name);
args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial.");
if (!args.Player.HasPermission(Permissions.usesundial))
{
TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission {args.Player.Name}");
args.Player.SendErrorMessage("You do not have permission to use the Enchanted Sundial.");
}
else if (TShock.Config.Settings.ForceTime != "normal")
{
TShock.Log.ConsoleDebug($"GetDataHandlers / HandleSpecial rejected enchanted sundial permission (ForceTime) {args.Player.Name}");
if (!args.Player.HasPermission(Permissions.cfgreload))
{
args.Player.SendErrorMessage("You cannot use the Enchanted Sundial because time is stopped.");
}
else
args.Player.SendErrorMessage("You must set ForceTime to normal via config to use the Enchanted Sundial.");
}
return true;
}

View file

@ -273,7 +273,7 @@ namespace TShockAPI
/// <summary>
/// Clears the permission list and sets it to the list provided,
/// will parse "!permssion" and add it to the negated permissions.
/// will parse "!permission" and add it to the negated permissions.
/// </summary>
/// <param name="permission">The new list of permissions to associate with the group.</param>
public void SetPermission(List<string> permission)

View file

@ -11,7 +11,7 @@ namespace TShockAPI.Handlers.NetModules
public class PylonHandler : INetModuleHandler
{
/// <summary>
/// Event occuring
/// Event occurring
/// </summary>
public SubPacketType PylonEventType { get; set; }
/// <summary>

View file

@ -85,7 +85,7 @@ namespace TShockAPI.Handlers
// At this point we should send our state back to the client so they remain in sync with the server
if (args.Handled == true)
{
args.Player.SendTileRect(args.TileX, args.TileY, args.Width, args.Length);
TSPlayer.All.SendTileRect(args.TileX, args.TileY, args.Width, args.Length);
TShock.Log.ConsoleDebug("Bouncer / SendTileRect reimplemented from carbonara from {0}", args.Player.Name);
}
}

View file

@ -119,7 +119,7 @@ namespace TShockAPI
/// Writes a message to the log
/// </summary>
/// <param name="message">Message to write</param>
/// <param name="level">LogLevel assosciated with the message</param>
/// <param name="level">LogLevel associated with the message</param>
void Write(string message, TraceLevel level);
/// <summary>
@ -152,4 +152,4 @@ namespace TShockAPI
/// </summary>
void Dispose();
}
}
}

View file

@ -399,7 +399,7 @@ namespace TShockAPI
[Description("User can use Creative UI to set world time speed.")]
public static readonly string journey_timespeed = "tshock.journey.time.setspeed";
[Description("User can use Creative UI to to toggle character godmode.")]
[Description("User can use Creative UI to toggle character godmode.")]
public static readonly string journey_godmode = "tshock.journey.godmode";
[Description("User can use Creative UI to set world wind strength/seed.")]

View file

@ -53,5 +53,5 @@ using System.Runtime.InteropServices;
// Also, be sure to release on github with the exact assembly version tag as below
// so that the update manager works correctly (via the Github releases api and mimic)
[assembly: AssemblyVersion("4.5.4")]
[assembly: AssemblyFileVersion("4.5.4")]
[assembly: AssemblyVersion("4.5.5")]
[assembly: AssemblyFileVersion("4.5.5")]

View file

@ -1117,7 +1117,7 @@ namespace TShockAPI
[Permission(RestPermissions.restmanagegroups)]
[Noun("group", true, "The name of the new group.", typeof(String))]
[Noun("parent", false, "The name of the parent group.", typeof(String))]
[Noun("permissions", false, "A comma seperated list of permissions for the new group.", typeof(String))]
[Noun("permissions", false, "A comma separated list of permissions for the new group.", typeof(String))]
[Noun("chatcolor", false, "A r,g,b string representing the color for this groups chat.", typeof(String))]
[Token]
private object GroupCreate(RestRequestArgs args)
@ -1142,7 +1142,7 @@ namespace TShockAPI
[Noun("group", true, "The name of the group to modify.", typeof(String))]
[Noun("parent", false, "The name of the new parent for this group.", typeof(String))]
[Noun("chatcolor", false, "The new chat color r,g,b.", typeof(String))]
[Noun("permissions", false, "The new comma seperated list of permissions.", typeof(String))]
[Noun("permissions", false, "The new comma separated list of permissions.", typeof(String))]
[Token]
private object GroupUpdate(RestRequestArgs args)
{

View file

@ -200,7 +200,7 @@ namespace TShockAPI.Sockets
this._listener.Stop();
// currently vanilla will stop listening when the slots are full, however it appears that this Netplay.IsListening
// flag is still set, making the server loop beleive it's still listening when it's actually not.
// flag is still set, making the server loop believe it's still listening when it's actually not.
// clearing this flag when we actually have stopped will allow the ServerLoop to start listening again when
// there are enough slots available.
Netplay.IsListening = false;

View file

@ -1018,7 +1018,7 @@ namespace TShockAPI
}
/// <summary>
/// Player Y cooridnate divided by 16. Supposed Y world coordinate.
/// Player Y coordinate divided by 16. Supposed Y world coordinate.
/// </summary>
public int TileY
{
@ -1526,8 +1526,10 @@ namespace TShockAPI
}
foo = foo.Replace("%map%", (TShock.Config.Settings.UseServerName ? TShock.Config.Settings.ServerName : Main.worldName));
foo = foo.Replace("%players%", String.Join(",", players));
foo = foo.Replace("%players%", String.Join(", ", players));
foo = foo.Replace("%specifier%", TShock.Config.Settings.CommandSpecifier);
foo = foo.Replace("%onlineplayers%", TShock.Utils.GetActivePlayerCount().ToString());
foo = foo.Replace("%serverslots%", TShock.Config.Settings.MaxSlots.ToString());
SendMessage(foo, lineColor);
}

View file

@ -182,12 +182,12 @@ namespace TShockAPI
public void RevertTiles(Dictionary<Vector2, ITile> tiles)
{
// Update Main.Tile first so that when tile sqaure is sent it is correct
// Update Main.Tile first so that when tile square is sent it is correct
foreach (KeyValuePair<Vector2, ITile> entry in tiles)
{
Main.tile[(int)entry.Key.X, (int)entry.Key.Y] = entry.Value;
}
// Send all players updated tile sqaures
// Send all players updated tile squares
foreach (Vector2 coords in tiles.Keys)
{
All.SendTileSquare((int)coords.X, (int)coords.Y, 3);

View file

@ -58,7 +58,7 @@ namespace TShockAPI
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
public static readonly string VersionCodename = "Blood Moon edition";
public static readonly string VersionCodename = "Olympics maybe?";
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
public static string SavePath = "tshock";
@ -1614,7 +1614,7 @@ namespace TShockAPI
}
/// <summary>OnProjectileSetDefaults - Called when a projectile sets the default attributes for itself.</summary>
/// <param name="e">e - The SetDefaultsEventArgs object praameterized with Projectile and int.</param>
/// <param name="e">e - The SetDefaultsEventArgs object parameterized with Projectile and int.</param>
private void OnProjectileSetDefaults(SetDefaultsEventArgs<Projectile, int> e)
{
//tombstone fix.

View file

@ -141,7 +141,7 @@ namespace TShockAPI
}
/// <summary>
/// Broadcasts a message from a Terraria playerplayer, not TShock
/// Broadcasts a message from a Terraria player, not TShock
/// </summary>
/// <param name="ply">ply - the Terraria player index that will send the packet</param>
/// <param name="msg">msg - The message to send</param>