From 4eebaf6c44b4824ce9d2e7eca680f4a846a4aeff Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 29 Dec 2017 08:50:13 -0700 Subject: [PATCH] Rename methods that were ambiguous in meaning. This renames some methods in the Utils class to better reflect what they do or what they provide back. It should be clearer what these methods are for now than before. --- CHANGELOG.md | 2 ++ TShockAPI/Bouncer.cs | 4 ++-- TShockAPI/FileTools.cs | 2 +- TShockAPI/Utils.cs | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f428630c..e9a0ab61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Removed `Utils.HasBanExpired()` and replaced with `Bans.RemoveBanIfExpired()`. (@hakusaro) * Removed `Utils.SendFileToUser()` and replaced with `TSPlayer.SendFileTextAsMessage()`. (@hakusaro) * Removed `Utils.GetGroup()` also have you seen `Groups.GetGroupByName()`? (@hakusaro) +* `Utils.MaxChests()` is now `Utils.HasWorldReachedMaxChests()`. (@hakusaro) +* `Utils.GetIPv4Address()` is now `Utils.GetIPv4AddressFromHostname()`. (@hakusaro) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index d334143b..6605f1e5 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -627,7 +627,7 @@ namespace TShockAPI && Main.tile[tileX, tileY].type != TileID.Containers && Main.tile[tileX, tileY].type != TileID.Dressers && Main.tile[tileX, tileY].type != TileID.Containers2 - && (!TShock.Utils.MaxChests() && Main.tile[tileX, tileY].type != TileID.Dirt)) //Chest + && (!TShock.Utils.HasWorldReachedMaxChests() && Main.tile[tileX, tileY].type != TileID.Dirt)) //Chest { args.Player.SendTileSquare(tileX, tileY, 3); args.Handled = true; @@ -1409,7 +1409,7 @@ namespace TShockAPI } if (action == EditAction.PlaceTile && (editData == TileID.Containers || editData == TileID.Containers2)) { - if (TShock.Utils.MaxChests()) + if (TShock.Utils.HasWorldReachedMaxChests()) { args.Player.SendErrorMessage("The world's chest limit has been reached - unable to place more."); args.Player.SendTileSquare(tileX, tileY, 3); diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index 6938149c..2690ef14 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -154,7 +154,7 @@ namespace TShockAPI { if (string.IsNullOrWhiteSpace(line)) continue; - contains = TShock.Utils.GetIPv4Address(line).Equals(ip); + contains = TShock.Utils.GetIPv4AddressFromHostname(line).Equals(ip); if (contains) return true; } diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 6c2f427d..fc550600 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -483,7 +483,7 @@ namespace TShockAPI /// Returns an IPv4 address from a DNS query /// /// string ip - public string GetIPv4Address(string hostname) + public string GetIPv4AddressFromHostname(string hostname) { try { @@ -502,7 +502,7 @@ namespace TShockAPI /// Checks if world has hit the max number of chests /// /// True if the entire chest array is used - public bool MaxChests() + public bool HasWorldReachedMaxChests() { for (int i = 0; i < Main.chest.Length; i++) {