parent
42a505e18f
commit
015cf61b77
3 changed files with 83 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ using System.Threading;
|
|||
using Terraria;
|
||||
using TShockAPI.DB;
|
||||
using TerrariaApi.Server;
|
||||
using TShockAPI.Hooks;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -228,6 +229,12 @@ namespace TShockAPI
|
|||
DoLog = false,
|
||||
HelpText = "Logs you into an account."
|
||||
});
|
||||
add(new Command(Permissions.canlogout, Logout, "logout")
|
||||
{
|
||||
AllowServer = false,
|
||||
DoLog = false,
|
||||
HelpText = "Logs you out of your current account."
|
||||
});
|
||||
add(new Command(Permissions.canchangepassword, PasswordUser, "password")
|
||||
{
|
||||
AllowServer = false,
|
||||
|
|
@ -442,6 +449,11 @@ namespace TShockAPI
|
|||
AllowServer = false,
|
||||
HelpText = "Teleports you to tile coordinates."
|
||||
});
|
||||
add(new Command(Permissions.getpos, GetPos, "pos")
|
||||
{
|
||||
AllowServer = false,
|
||||
HelpText = "Returns the user's or specified user's current position."
|
||||
});
|
||||
add(new Command(Permissions.tpallow, TPAllow, "tpallow")
|
||||
{
|
||||
AllowServer = false,
|
||||
|
|
@ -845,6 +857,26 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
private static void Logout(CommandArgs args)
|
||||
{
|
||||
if (!args.Player.IsLoggedIn)
|
||||
{
|
||||
args.Player.SendErrorMessage("You are not logged in.");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHooks.OnPlayerLogout(args.Player);
|
||||
|
||||
args.Player.PlayerData = new PlayerData(args.Player);
|
||||
args.Player.Group = null;
|
||||
args.Player.tempGroup = TShockAPI.Group.DefaultGroup;
|
||||
args.Player.UserAccountName = null;
|
||||
args.Player.UserID = -1;
|
||||
args.Player.IsLoggedIn = false;
|
||||
|
||||
args.Player.SendSuccessMessage("You have been successfully logged out of your account.");
|
||||
}
|
||||
|
||||
private static void PasswordUser(CommandArgs args)
|
||||
{
|
||||
try
|
||||
|
|
@ -2324,6 +2356,29 @@ namespace TShockAPI
|
|||
args.Player.SendSuccessMessage("Teleported to the '{0}'.", target.name);
|
||||
}
|
||||
|
||||
private static void GetPos(CommandArgs args)
|
||||
{
|
||||
var player = args.Player.Name;
|
||||
if (args.Parameters.Count > 0)
|
||||
{
|
||||
player = String.Join(" ", args.Parameters);
|
||||
}
|
||||
|
||||
var players = TShock.Utils.FindPlayer(player);
|
||||
if (players.Count == 0)
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid player!");
|
||||
}
|
||||
else if (players.Count > 1)
|
||||
{
|
||||
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendSuccessMessage("Location of {0} is ({1}, {2}).", players[0].Name, players[0].TileX, players[0].TileY);
|
||||
}
|
||||
}
|
||||
|
||||
private static void TPPos(CommandArgs args)
|
||||
{
|
||||
if (args.Parameters.Count != 2)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,16 @@ namespace TShockAPI.Hooks
|
|||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class PlayerLogoutEventArgs
|
||||
{
|
||||
public TSPlayer Player { get; set; }
|
||||
|
||||
public PlayerLogoutEventArgs(TSPlayer player)
|
||||
{
|
||||
Player = player;
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerCommandEventArgs : HandledEventArgs
|
||||
{
|
||||
public TSPlayer Player { get; set; }
|
||||
|
|
@ -62,6 +72,9 @@ namespace TShockAPI.Hooks
|
|||
public delegate void PlayerPreLoginD(PlayerPreLoginEventArgs e);
|
||||
public static event PlayerPreLoginD PlayerPreLogin;
|
||||
|
||||
public delegate void PlayerLogoutD(PlayerLogoutEventArgs e);
|
||||
public static event PlayerLogoutD PlayerLogout;
|
||||
|
||||
public delegate void PlayerCommandD(PlayerCommandEventArgs e);
|
||||
public static event PlayerCommandD PlayerCommand;
|
||||
|
||||
|
|
@ -108,6 +121,15 @@ namespace TShockAPI.Hooks
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
public static void OnPlayerLogout(TSPlayer ply)
|
||||
{
|
||||
if (PlayerLogout == null)
|
||||
return;
|
||||
|
||||
var args = new PlayerLogoutEventArgs(ply);
|
||||
PlayerLogout(args);
|
||||
}
|
||||
|
||||
public static void OnPlayerChat(TSPlayer ply, string rawtext, ref string tshockText)
|
||||
{
|
||||
if (PlayerChat == null)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ namespace TShockAPI
|
|||
[Description("User can login in game")]
|
||||
public static readonly string canlogin = "tshock.account.login";
|
||||
|
||||
[Description("User can logout in game")]
|
||||
public static readonly string canlogout = "tshock.account.logout";
|
||||
|
||||
[Description("User can change password in game")]
|
||||
public static readonly string canchangepassword = "tshock.account.changepassword";
|
||||
|
||||
|
|
@ -225,6 +228,9 @@ namespace TShockAPI
|
|||
[Description("User can teleport to tile positions.")]
|
||||
public static readonly string tppos = "tshock.tp.pos";
|
||||
|
||||
[Description("User can get the position of players.")]
|
||||
public static readonly string getpos = "tshock.tp.getpos";
|
||||
|
||||
[Description("User can teleport to an NPC.")]
|
||||
public static readonly string tpnpc = "tshock.tp.npc";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue