Removed deprecation messages. This is a new version already.
This commit is contained in:
parent
8ba1aa58ac
commit
a9788f4576
1 changed files with 204 additions and 236 deletions
|
|
@ -16,15 +16,15 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using TShockAPI.PluginUpdater;
|
using TShockAPI.PluginUpdater;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using TShockAPI.DB;
|
using TShockAPI.DB;
|
||||||
|
|
@ -71,16 +71,16 @@ namespace TShockAPI
|
||||||
public List<string> Permissions { get; protected set; }
|
public List<string> Permissions { get; protected set; }
|
||||||
|
|
||||||
private CommandDelegate commandDelegate;
|
private CommandDelegate commandDelegate;
|
||||||
public CommandDelegate CommandDelegate
|
public CommandDelegate CommandDelegate
|
||||||
{
|
{
|
||||||
get { return commandDelegate; }
|
get { return commandDelegate; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
commandDelegate = value;
|
commandDelegate = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command(List<string> permissionsneeded, CommandDelegate cmd, params string[] names)
|
public Command(List<string> permissionsneeded, CommandDelegate cmd, params string[] names)
|
||||||
|
|
@ -154,10 +154,10 @@ namespace TShockAPI
|
||||||
public static void InitCommands()
|
public static void InitCommands()
|
||||||
{
|
{
|
||||||
List<Command> tshockCommands = new List<Command>(100);
|
List<Command> tshockCommands = new List<Command>(100);
|
||||||
Action<Command> add2 = (cmd) =>
|
Action<Command> add2 = (cmd) =>
|
||||||
{
|
{
|
||||||
tshockCommands.Add(cmd);
|
tshockCommands.Add(cmd);
|
||||||
ChatCommands.Add(cmd);
|
ChatCommands.Add(cmd);
|
||||||
};
|
};
|
||||||
AddChatCommand add = (p, c, n) => add2(new Command(p, c, n));
|
AddChatCommand add = (p, c, n) => add2(new Command(p, c, n));
|
||||||
|
|
||||||
|
|
@ -177,7 +177,6 @@ namespace TShockAPI
|
||||||
add2(new Command(Permissions.tphere, TPHere, "tphere") { AllowServer = false });
|
add2(new Command(Permissions.tphere, TPHere, "tphere") { AllowServer = false });
|
||||||
add2(new Command(Permissions.tpallow, TPAllow, "tpallow") { AllowServer = false });
|
add2(new Command(Permissions.tpallow, TPAllow, "tpallow") { AllowServer = false });
|
||||||
add(Permissions.kick, Kick, "kick");
|
add(Permissions.kick, Kick, "kick");
|
||||||
add(Permissions.ban, DeprecateBans, "banip", "listbans", "unban", "unbanip", "clearbans");
|
|
||||||
add(Permissions.ban, Ban, "ban");
|
add(Permissions.ban, Ban, "ban");
|
||||||
add(Permissions.whitelist, Whitelist, "whitelist");
|
add(Permissions.whitelist, Whitelist, "whitelist");
|
||||||
add(Permissions.maintenance, Off, "off", "exit");
|
add(Permissions.maintenance, Off, "off", "exit");
|
||||||
|
|
@ -201,8 +200,6 @@ namespace TShockAPI
|
||||||
add(Permissions.spawnboss, Hardcore, "hardcore");
|
add(Permissions.spawnboss, Hardcore, "hardcore");
|
||||||
add(Permissions.spawnmob, SpawnMob, "spawnmob", "sm");
|
add(Permissions.spawnmob, SpawnMob, "spawnmob", "sm");
|
||||||
add(Permissions.warp, Warp, "warp");
|
add(Permissions.warp, Warp, "warp");
|
||||||
add(Permissions.managewarp, DeprecateWarp, "setwarp", "delwarp", "hidewarp");
|
|
||||||
add(Permissions.tphere, DeprecateWarp, "sendwarp", "sw");
|
|
||||||
add(Permissions.managegroup, AddGroup, "addgroup");
|
add(Permissions.managegroup, AddGroup, "addgroup");
|
||||||
add(Permissions.managegroup, DeleteGroup, "delgroup");
|
add(Permissions.managegroup, DeleteGroup, "delgroup");
|
||||||
add(Permissions.managegroup, ModifyGroup, "modgroup");
|
add(Permissions.managegroup, ModifyGroup, "modgroup");
|
||||||
|
|
@ -859,21 +856,10 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeprecateBans(CommandArgs args)
|
|
||||||
{
|
|
||||||
args.Player.SendInfoMessage("All ban commands were merged into one in TShock 4.0.");
|
|
||||||
args.Player.SendInfoMessage("Syntax: /ban [option] [arguments]");
|
|
||||||
args.Player.SendInfoMessage("Options: list, listip, clear, add, addip, del, delip");
|
|
||||||
args.Player.SendInfoMessage("Arguments: list, listip, clear [code], add [name], addip [ip], del [name], delip [name]");
|
|
||||||
args.Player.SendInfoMessage("In addition, a reason may be provided for all new bans after the arguments.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Ban(CommandArgs args)
|
private static void Ban(CommandArgs args)
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count == 0 || args.Parameters[0].ToLower() == "help")
|
if (args.Parameters.Count == 0 || args.Parameters[0].ToLower() == "help")
|
||||||
{
|
{
|
||||||
args.Player.SendInfoMessage("All ban commands were merged into one in TShock 4.0.");
|
|
||||||
args.Player.SendInfoMessage("Syntax: /ban [option] [arguments]");
|
args.Player.SendInfoMessage("Syntax: /ban [option] [arguments]");
|
||||||
args.Player.SendInfoMessage("Options: list, listip, clear, add, addip, del, delip");
|
args.Player.SendInfoMessage("Options: list, listip, clear, add, addip, del, delip");
|
||||||
args.Player.SendInfoMessage("Arguments: list, listip, clear [code], add [name], addip [ip], del [name], delip [name]");
|
args.Player.SendInfoMessage("Arguments: list, listip, clear [code], add [name], addip [ip], del [name], delip [name]");
|
||||||
|
|
@ -1181,10 +1167,10 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static void OverrideSSI( CommandArgs args )
|
public static void OverrideSSI( CommandArgs args )
|
||||||
{
|
{
|
||||||
if (!TShock.Config.ServerSideInventory)
|
if (!TShock.Config.ServerSideInventory)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Server Side Inventory is disabled.");
|
args.Player.SendErrorMessage("Server Side Inventory is disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( args.Parameters.Count < 1 )
|
if( args.Parameters.Count < 1 )
|
||||||
{
|
{
|
||||||
|
|
@ -1206,20 +1192,20 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
TSPlayer matchedPlayer = matchedPlayers[0];
|
TSPlayer matchedPlayer = matchedPlayers[0];
|
||||||
if (matchedPlayer.IsLoggedIn)
|
if (matchedPlayer.IsLoggedIn)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Player \"{0}\" is already logged in.", matchedPlayer.Name);
|
args.Player.SendErrorMessage("Player \"{0}\" is already logged in.", matchedPlayer.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!matchedPlayer.LoginFailsBySsi)
|
if (!matchedPlayer.LoginFailsBySsi)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Player \"{0}\" has to perform a /login attempt first.", matchedPlayer.Name);
|
args.Player.SendErrorMessage("Player \"{0}\" has to perform a /login attempt first.", matchedPlayer.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (matchedPlayer.IgnoreActionsForClearingTrashCan)
|
if (matchedPlayer.IgnoreActionsForClearingTrashCan)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Player \"{0}\" has to reconnect first.", matchedPlayer.Name);
|
args.Player.SendErrorMessage("Player \"{0}\" has to reconnect first.", matchedPlayer.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TShock.InventoryDB.InsertPlayerData(matchedPlayer);
|
TShock.InventoryDB.InsertPlayerData(matchedPlayer);
|
||||||
|
|
@ -1784,17 +1770,6 @@ namespace TShockAPI
|
||||||
args.Player.TPAllow = !args.Player.TPAllow;
|
args.Player.TPAllow = !args.Player.TPAllow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeprecateWarp(CommandArgs args)
|
|
||||||
{
|
|
||||||
args.Player.SendInfoMessage("All warp commands were merged into one in TShock 4.0.");
|
|
||||||
args.Player.SendInfoMessage("Previous warps with spaces should be wrapped in single quotes.");
|
|
||||||
args.Player.SendInfoMessage("Invalid syntax. Syntax: /warp [command] [arguments]");
|
|
||||||
args.Player.SendInfoMessage("Commands: add, del, hide, list, send, [warpname]");
|
|
||||||
args.Player.SendInfoMessage("Arguments: add [warp name], del [warp name], list [page]");
|
|
||||||
args.Player.SendInfoMessage("Arguments: send [player] [warp name], hide [warp name] [Enable(true/false)]");
|
|
||||||
args.Player.SendInfoMessage("Examples: /warp add foobar, /warp hide foobar true, /warp foobar");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Warp(CommandArgs args)
|
private static void Warp(CommandArgs args)
|
||||||
{
|
{
|
||||||
bool hasManageWarpPermission = args.Player.Group.HasPermission(Permissions.managewarp);
|
bool hasManageWarpPermission = args.Player.Group.HasPermission(Permissions.managewarp);
|
||||||
|
|
@ -1802,8 +1777,6 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (hasManageWarpPermission)
|
if (hasManageWarpPermission)
|
||||||
{
|
{
|
||||||
args.Player.SendInfoMessage("All warp commands were merged into one in TShock 4.0.");
|
|
||||||
args.Player.SendInfoMessage("Previous warps with spaces should be wrapped in single quotes.");
|
|
||||||
args.Player.SendInfoMessage("Invalid syntax. Syntax: /warp [command] [arguments]");
|
args.Player.SendInfoMessage("Invalid syntax. Syntax: /warp [command] [arguments]");
|
||||||
args.Player.SendInfoMessage("Commands: add, del, hide, list, send, [warpname]");
|
args.Player.SendInfoMessage("Commands: add, del, hide, list, send, [warpname]");
|
||||||
args.Player.SendInfoMessage("Arguments: add [warp name], del [warp name], list [page]");
|
args.Player.SendInfoMessage("Arguments: add [warp name], del [warp name], list [page]");
|
||||||
|
|
@ -1814,8 +1787,6 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid syntax. Syntax: /warp [name] or /warp list <page>");
|
args.Player.SendErrorMessage("Invalid syntax. Syntax: /warp [name] or /warp list <page>");
|
||||||
args.Player.SendErrorMessage("Previous warps with spaces should be wrapped in single quotes.");
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1896,7 +1867,6 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /warp add [name]");
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /warp add [name]");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args.Parameters[0].ToLower() == "del" && hasManageWarpPermission)
|
else if (args.Parameters[0].ToLower() == "del" && hasManageWarpPermission)
|
||||||
{
|
{
|
||||||
|
|
@ -1912,7 +1882,6 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /warp del [name]");
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /warp del [name]");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (args.Parameters[0].ToLower() == "hide" && hasManageWarpPermission)
|
else if (args.Parameters[0].ToLower() == "hide" && hasManageWarpPermission)
|
||||||
{
|
{
|
||||||
|
|
@ -1976,7 +1945,6 @@ namespace TShockAPI
|
||||||
args.Player.SendErrorMessage("Specified warp not found.");
|
args.Player.SendErrorMessage("Specified warp not found.");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2830,12 +2798,12 @@ namespace TShockAPI
|
||||||
);
|
);
|
||||||
|
|
||||||
PaginationTools.SendPage(
|
PaginationTools.SendPage(
|
||||||
args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(regionNames),
|
args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(regionNames),
|
||||||
new PaginationTools.Settings
|
new PaginationTools.Settings
|
||||||
{
|
{
|
||||||
HeaderFormat = "List of Regions ({0}/{1})",
|
HeaderFormat = "List of Regions ({0}/{1})",
|
||||||
FooterFormat = "Type /region list {0} for more.",
|
FooterFormat = "Type /region list {0} for more.",
|
||||||
NothingToDisplayString = "There are currently no regions defined."
|
NothingToDisplayString = "There are currently no regions defined."
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -2843,10 +2811,10 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
case "info":
|
case "info":
|
||||||
{
|
{
|
||||||
if (args.Parameters.Count == 1 || args.Parameters.Count > 4)
|
if (args.Parameters.Count == 1 || args.Parameters.Count > 4)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region info <region> [-d] [page]");
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region info <region> [-d] [page]");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string regionName = args.Parameters[1];
|
string regionName = args.Parameters[1];
|
||||||
|
|
@ -2866,87 +2834,87 @@ namespace TShockAPI
|
||||||
if (!PaginationTools.TryParsePageNumber(args.Parameters, pageNumberIndex, args.Player, out pageNumber))
|
if (!PaginationTools.TryParsePageNumber(args.Parameters, pageNumberIndex, args.Player, out pageNumber))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
List<string> lines = new List<string>
|
List<string> lines = new List<string>
|
||||||
{
|
{
|
||||||
string.Format("X: {0}; Y: {1}; W: {2}; H: {3}, Z: {4}", region.Area.X, region.Area.Y, region.Area.Width, region.Area.Height, region.Z),
|
string.Format("X: {0}; Y: {1}; W: {2}; H: {3}, Z: {4}", region.Area.X, region.Area.Y, region.Area.Width, region.Area.Height, region.Z),
|
||||||
string.Concat("Owner: ", region.Owner),
|
string.Concat("Owner: ", region.Owner),
|
||||||
string.Concat("Protected: ", region.DisableBuild.ToString()),
|
string.Concat("Protected: ", region.DisableBuild.ToString()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (region.AllowedIDs.Count > 0)
|
if (region.AllowedIDs.Count > 0)
|
||||||
{
|
{
|
||||||
IEnumerable<string> sharedUsersSelector = region.AllowedIDs.Select(userId =>
|
IEnumerable<string> sharedUsersSelector = region.AllowedIDs.Select(userId =>
|
||||||
{
|
{
|
||||||
User user = TShock.Users.GetUserByID(userId);
|
User user = TShock.Users.GetUserByID(userId);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
return user.Name;
|
return user.Name;
|
||||||
else
|
else
|
||||||
return string.Concat("{ID: ", userId, "}");
|
return string.Concat("{ID: ", userId, "}");
|
||||||
});
|
});
|
||||||
List<string> extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct());
|
List<string> extraLines = PaginationTools.BuildLinesFromTerms(sharedUsersSelector.Distinct());
|
||||||
extraLines[0] = "Shared with: " + extraLines[0];
|
extraLines[0] = "Shared with: " + extraLines[0];
|
||||||
lines.AddRange(extraLines);
|
lines.AddRange(extraLines);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lines.Add("Region is not shared with any users.");
|
lines.Add("Region is not shared with any users.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region.AllowedGroups.Count > 0)
|
if (region.AllowedGroups.Count > 0)
|
||||||
{
|
{
|
||||||
List<string> extraLines = PaginationTools.BuildLinesFromTerms(region.AllowedGroups.Distinct());
|
List<string> extraLines = PaginationTools.BuildLinesFromTerms(region.AllowedGroups.Distinct());
|
||||||
extraLines[0] = "Shared with groups: " + extraLines[0];
|
extraLines[0] = "Shared with groups: " + extraLines[0];
|
||||||
lines.AddRange(extraLines);
|
lines.AddRange(extraLines);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lines.Add("Region is not shared with any groups.");
|
lines.Add("Region is not shared with any groups.");
|
||||||
}
|
}
|
||||||
|
|
||||||
PaginationTools.SendPage(
|
PaginationTools.SendPage(
|
||||||
args.Player, pageNumber, lines, new PaginationTools.Settings
|
args.Player, pageNumber, lines, new PaginationTools.Settings
|
||||||
{
|
{
|
||||||
HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name),
|
HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name),
|
||||||
FooterFormat = "Type /region info {0} for more information."
|
FooterFormat = "Type /region info {0} for more information."
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (displayBoundaries)
|
if (displayBoundaries)
|
||||||
{
|
{
|
||||||
Rectangle regionArea = region.Area;
|
Rectangle regionArea = region.Area;
|
||||||
foreach (Point boundaryPoint in Utils.Instance.EnumerateRegionBoundaries(regionArea))
|
foreach (Point boundaryPoint in Utils.Instance.EnumerateRegionBoundaries(regionArea))
|
||||||
{
|
{
|
||||||
// Preferring dotted lines as those should easily be distinguishable from actual wires.
|
// Preferring dotted lines as those should easily be distinguishable from actual wires.
|
||||||
if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0)
|
if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0)
|
||||||
{
|
{
|
||||||
// Could be improved by sending raw tile data to the client instead but not really
|
// Could be improved by sending raw tile data to the client instead but not really
|
||||||
// worth the effort as chances are very low that overwriting the wire for a few
|
// worth the effort as chances are very low that overwriting the wire for a few
|
||||||
// nanoseconds will cause much trouble.
|
// nanoseconds will cause much trouble.
|
||||||
Tile tile = Main.tile[boundaryPoint.X, boundaryPoint.Y];
|
Tile tile = Main.tile[boundaryPoint.X, boundaryPoint.Y];
|
||||||
bool oldWireState = tile.wire;
|
bool oldWireState = tile.wire;
|
||||||
tile.wire = true;
|
tile.wire = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
||||||
} finally {
|
} finally {
|
||||||
tile.wire = oldWireState;
|
tile.wire = oldWireState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer boundaryHideTimer = null;
|
Timer boundaryHideTimer = null;
|
||||||
boundaryHideTimer = new Timer((state) => {
|
boundaryHideTimer = new Timer((state) => {
|
||||||
foreach (Point boundaryPoint in Utils.Instance.EnumerateRegionBoundaries(regionArea))
|
foreach (Point boundaryPoint in Utils.Instance.EnumerateRegionBoundaries(regionArea))
|
||||||
if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0)
|
if ((boundaryPoint.X + boundaryPoint.Y & 1) == 0)
|
||||||
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
args.Player.SendTileSquare(boundaryPoint.X, boundaryPoint.Y, 1);
|
||||||
|
|
||||||
// ReSharper disable AccessToModifiedClosure
|
// ReSharper disable AccessToModifiedClosure
|
||||||
Debug.Assert(boundaryHideTimer != null);
|
Debug.Assert(boundaryHideTimer != null);
|
||||||
boundaryHideTimer.Dispose();
|
boundaryHideTimer.Dispose();
|
||||||
// ReSharper restore AccessToModifiedClosure
|
// ReSharper restore AccessToModifiedClosure
|
||||||
},
|
},
|
||||||
null, 5000, Timeout.Infinite
|
null, 5000, Timeout.Infinite
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -3031,67 +2999,67 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
case "tp":
|
case "tp":
|
||||||
{
|
{
|
||||||
if (!args.Player.Group.HasPermission(Permissions.tp))
|
if (!args.Player.Group.HasPermission(Permissions.tp))
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("You don't have the necessary permission to do that.");
|
args.Player.SendErrorMessage("You don't have the necessary permission to do that.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (args.Parameters.Count <= 1)
|
if (args.Parameters.Count <= 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region tp <region>.");
|
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region tp <region>.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
string regionName = string.Join(" ", args.Parameters.Skip(1));
|
string regionName = string.Join(" ", args.Parameters.Skip(1));
|
||||||
Region region = TShock.Regions.GetRegionByName(regionName);
|
Region region = TShock.Regions.GetRegionByName(regionName);
|
||||||
if (region == null)
|
if (region == null)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Region \"{0}\" does not exist.", regionName);
|
args.Player.SendErrorMessage("Region \"{0}\" does not exist.", regionName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Player.Teleport(region.Area.Center.X, region.Area.Center.Y + 3);
|
args.Player.Teleport(region.Area.Center.X, region.Area.Center.Y + 3);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "help":
|
case "help":
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int pageNumber;
|
int pageNumber;
|
||||||
int pageParamIndex = 0;
|
int pageParamIndex = 0;
|
||||||
if (args.Parameters.Count > 1)
|
if (args.Parameters.Count > 1)
|
||||||
pageParamIndex = 1;
|
pageParamIndex = 1;
|
||||||
if (!PaginationTools.TryParsePageNumber(args.Parameters, pageParamIndex, args.Player, out pageNumber))
|
if (!PaginationTools.TryParsePageNumber(args.Parameters, pageParamIndex, args.Player, out pageNumber))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<string> lines = new List<string> {
|
List<string> lines = new List<string> {
|
||||||
"set <1/2> - Sets the temporary region points.",
|
"set <1/2> - Sets the temporary region points.",
|
||||||
"clear - Clears the temporary region points.",
|
"clear - Clears the temporary region points.",
|
||||||
"define <name> - Defines the region with the given name.",
|
"define <name> - Defines the region with the given name.",
|
||||||
"delete <name> - Deletes the given region.",
|
"delete <name> - Deletes the given region.",
|
||||||
"name [-u][-z][-p] - Shows the name of the region at the given point.",
|
"name [-u][-z][-p] - Shows the name of the region at the given point.",
|
||||||
"list - Lists all regions.",
|
"list - Lists all regions.",
|
||||||
"resize <region> <u/d/l/r> <amount> - Resizes a region.",
|
"resize <region> <u/d/l/r> <amount> - Resizes a region.",
|
||||||
"allow <user> <region> - Allows a user to a region.",
|
"allow <user> <region> - Allows a user to a region.",
|
||||||
"remove <user> <region> - Removes a user from a region.",
|
"remove <user> <region> - Removes a user from a region.",
|
||||||
"allowg <group> <region> - Allows a user group to a region.",
|
"allowg <group> <region> - Allows a user group to a region.",
|
||||||
"removeg <group> <region> - Removes a user group from a region.",
|
"removeg <group> <region> - Removes a user group from a region.",
|
||||||
"info <region> [-d] - Displays several information about the given region.",
|
"info <region> [-d] - Displays several information about the given region.",
|
||||||
"protect <name> <true/false> - Sets whether the tiles inside the region are protected or not.",
|
"protect <name> <true/false> - Sets whether the tiles inside the region are protected or not.",
|
||||||
"z <name> <#> - Sets the z-order of the region.",
|
"z <name> <#> - Sets the z-order of the region.",
|
||||||
};
|
};
|
||||||
if (args.Player.Group.HasPermission(Permissions.tp))
|
if (args.Player.Group.HasPermission(Permissions.tp))
|
||||||
lines.Add("tp <region> - Teleports you to the given region's center.");
|
lines.Add("tp <region> - Teleports you to the given region's center.");
|
||||||
|
|
||||||
PaginationTools.SendPage(
|
PaginationTools.SendPage(
|
||||||
args.Player, pageNumber, lines,
|
args.Player, pageNumber, lines,
|
||||||
new PaginationTools.Settings
|
new PaginationTools.Settings
|
||||||
{
|
{
|
||||||
HeaderFormat = "Available Region Sub-Commands ({0}/{1}):",
|
HeaderFormat = "Available Region Sub-Commands ({0}/{1}):",
|
||||||
FooterFormat = "Type /region {0} for more sub-commands."
|
FooterFormat = "Type /region {0} for more sub-commands."
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3495,22 +3463,22 @@ namespace TShockAPI
|
||||||
|
|
||||||
int amountParamIndex = -1;
|
int amountParamIndex = -1;
|
||||||
int itemAmount = 0;
|
int itemAmount = 0;
|
||||||
for (int i = 1; i < args.Parameters.Count; i++)
|
for (int i = 1; i < args.Parameters.Count; i++)
|
||||||
{
|
{
|
||||||
if (int.TryParse(args.Parameters[i], out itemAmount))
|
if (int.TryParse(args.Parameters[i], out itemAmount))
|
||||||
{
|
{
|
||||||
amountParamIndex = i;
|
amountParamIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string itemNameOrId;
|
string itemNameOrId;
|
||||||
if (amountParamIndex == -1)
|
if (amountParamIndex == -1)
|
||||||
itemNameOrId = string.Join(" ", args.Parameters);
|
itemNameOrId = string.Join(" ", args.Parameters);
|
||||||
else
|
else
|
||||||
itemNameOrId = string.Join(" ", args.Parameters.Take(amountParamIndex));
|
itemNameOrId = string.Join(" ", args.Parameters.Take(amountParamIndex));
|
||||||
|
|
||||||
Item item;
|
Item item;
|
||||||
List<Item> matchedItems = TShock.Utils.GetItemByIdOrName(itemNameOrId);
|
List<Item> matchedItems = TShock.Utils.GetItemByIdOrName(itemNameOrId);
|
||||||
if (matchedItems.Count == 0)
|
if (matchedItems.Count == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3522,37 +3490,37 @@ namespace TShockAPI
|
||||||
args.Player.SendErrorMessage("More than one item matched:");
|
args.Player.SendErrorMessage("More than one item matched:");
|
||||||
args.Player.SendErrorMessage(string.Join(", ", matchedItems.Select(i => i.name)));
|
args.Player.SendErrorMessage(string.Join(", ", matchedItems.Select(i => i.name)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = matchedItems[0];
|
item = matchedItems[0];
|
||||||
}
|
}
|
||||||
if (item.type < 1 && item.type >= Main.maxItemTypes)
|
if (item.type < 1 && item.type >= Main.maxItemTypes)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("The item type {0} is invalid.", itemNameOrId);
|
args.Player.SendErrorMessage("The item type {0} is invalid.", itemNameOrId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prefixId = 0;
|
int prefixId = 0;
|
||||||
if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
|
if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
|
||||||
{
|
{
|
||||||
string prefixidOrName = args.Parameters[amountParamIndex + 1];
|
string prefixidOrName = args.Parameters[amountParamIndex + 1];
|
||||||
List<int> matchedPrefixIds = TShock.Utils.GetPrefixByIdOrName(prefixidOrName);
|
List<int> matchedPrefixIds = TShock.Utils.GetPrefixByIdOrName(prefixidOrName);
|
||||||
if (matchedPrefixIds.Count > 1)
|
if (matchedPrefixIds.Count > 1)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("More than one ({0}) prefixes matched \"{1}\".", matchedPrefixIds.Count, prefixidOrName);
|
args.Player.SendErrorMessage("More than one ({0}) prefixes matched \"{1}\".", matchedPrefixIds.Count, prefixidOrName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (matchedPrefixIds.Count == 0)
|
else if (matchedPrefixIds.Count == 0)
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("No prefix matched \"{0}\".", prefixidOrName);
|
args.Player.SendErrorMessage("No prefix matched \"{0}\".", prefixidOrName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prefixId = matchedPrefixIds[0];
|
prefixId = matchedPrefixIds[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Player.InventorySlotAvailable || item.name.Contains("Coin"))
|
if (args.Player.InventorySlotAvailable || item.name.Contains("Coin"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue