Merge branch 'master' of git://github.com/TShock/TShock
This commit is contained in:
commit
93e381a0a7
9 changed files with 98 additions and 56 deletions
|
|
@ -177,19 +177,18 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (cmd == null)
|
if (cmd == null)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cmd.CanRun(player))
|
||||||
|
{
|
||||||
|
Tools.SendLogs(string.Format("{0} tried to execute {1}", player.Name, cmd.Name), Color.Red);
|
||||||
|
player.SendMessage("You do not have access to that command.", Color.Red);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmd.CanRun(player))
|
Tools.SendLogs(string.Format("{0} executed: /{1}", player.Name, cmdText), Color.Red);
|
||||||
{
|
cmd.Run(cmdText, player, args);
|
||||||
Tools.SendLogs(string.Format("{0} tried to execute {1}", player.Name, cmd.Name), Color.Red);
|
|
||||||
player.SendMessage("You do not have access to that command.", Color.Red);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Tools.SendLogs(string.Format("{0} executed: /{1}", player.Name, cmdText), Color.Red);
|
|
||||||
cmd.Run(cmdText, player, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -655,20 +654,38 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static void Home(CommandArgs args)
|
private static void Home(CommandArgs args)
|
||||||
{
|
{
|
||||||
TShock.Teleport(args.Player.Index, args.TPlayer.SpawnX * 16 + 8 - args.TPlayer.width / 2,
|
if (!args.Player.RealPlayer)
|
||||||
args.TPlayer.SpawnY * 16 - args.TPlayer.height);
|
{
|
||||||
|
args.Player.SendMessage("You cant use teleport commands!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.Player.Spawn();
|
||||||
args.Player.SendMessage("Teleported to your spawnpoint.");
|
args.Player.SendMessage("Teleported to your spawnpoint.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Spawn(CommandArgs args)
|
private static void Spawn(CommandArgs args)
|
||||||
{
|
{
|
||||||
TShock.Teleport(args.Player.Index, Main.spawnTileX * 16 + 8 - args.TPlayer.width / 2,
|
if (!args.Player.RealPlayer)
|
||||||
Main.spawnTileY * 16 - args.TPlayer.height);
|
{
|
||||||
args.Player.SendMessage("Teleported to the map's spawnpoint.");
|
args.Player.SendMessage("You cant use teleport commands!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Player.Teleport(Main.spawnTileX, Main.spawnTileY))
|
||||||
|
args.Player.SendMessage("Teleported to the map's spawnpoint.");
|
||||||
|
else
|
||||||
|
args.Player.SendMessage("Can't teleport because you have set custom spawnpoint.", Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TP(CommandArgs args)
|
private static void TP(CommandArgs args)
|
||||||
{
|
{
|
||||||
|
if (!args.Player.RealPlayer)
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("You cant use teleport commands!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.Parameters.Count < 1)
|
if (args.Parameters.Count < 1)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /tp <player> ", Color.Red);
|
args.Player.SendMessage("Invalid syntax! Proper syntax: /tp <player> ", Color.Red);
|
||||||
|
|
@ -684,13 +701,21 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var plr = players[0];
|
var plr = players[0];
|
||||||
TShock.Teleport(args.Player.Index, plr.X, plr.Y);
|
if (args.Player.Teleport(plr.TileX, plr.TileY))
|
||||||
args.Player.SendMessage(string.Format("Teleported to {0}", plr.Name));
|
args.Player.SendMessage(string.Format("Teleported to {0}", plr.Name));
|
||||||
|
else
|
||||||
|
args.Player.SendMessage("Can't teleport because you have set custom spawnpoint.", Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TPHere(CommandArgs args)
|
private static void TPHere(CommandArgs args)
|
||||||
{
|
{
|
||||||
|
if (!args.Player.RealPlayer)
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("You cant use teleport commands!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.Parameters.Count < 1)
|
if (args.Parameters.Count < 1)
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /tphere <player> ", Color.Red);
|
args.Player.SendMessage("Invalid syntax! Proper syntax: /tphere <player> ", Color.Red);
|
||||||
|
|
@ -710,9 +735,14 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var plr = players[0];
|
var plr = players[0];
|
||||||
TShock.Teleport(plr.Index, args.Player.X, args.Player.Y);
|
if (plr.Teleport(args.Player.TileX, args.Player.TileY))
|
||||||
plr.SendMessage(string.Format("You were teleported to {0}.", plr.Name));
|
{
|
||||||
args.Player.SendMessage(string.Format("You brought {0} here.", plr.Name));
|
plr.SendMessage(string.Format("You were teleported to {0}.", plr.Name));
|
||||||
|
args.Player.SendMessage(string.Format("You brought {0} here.", plr.Name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
args.Player.SendMessage("Can't teleport because target player has set custom spawnpoint.", Color.Red);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StreamBinary;
|
|
||||||
using Terraria;
|
using Terraria;
|
||||||
using TerrariaAPI;
|
using TerrariaAPI;
|
||||||
|
using XNAHelpers;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -117,16 +117,14 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackTrace trace = new StackTrace();
|
string caller = "TShock";
|
||||||
StackFrame frame = null;
|
|
||||||
|
|
||||||
frame = trace.GetFrame(2);
|
StackFrame frame = new StackTrace().GetFrame(2);
|
||||||
|
if (frame != null)
|
||||||
string caller = "TShock: ";
|
|
||||||
|
|
||||||
if (frame != null && frame.GetMethod().DeclaringType != null)
|
|
||||||
{
|
{
|
||||||
caller += frame.GetMethod().DeclaringType.Name + ": ";
|
var meth = frame.GetMethod();
|
||||||
|
if (meth != null)
|
||||||
|
caller = meth.DeclaringType.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}",
|
_logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}",
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.1.0.0618")]
|
[assembly: AssemblyVersion("2.2.0.0620")]
|
||||||
[assembly: AssemblyFileVersion("2.1.0.0618")]
|
[assembly: AssemblyFileVersion("2.2.0.0620")]
|
||||||
|
|
@ -130,6 +130,31 @@ namespace TShockAPI
|
||||||
NetMessage.SendData((int)PacketTypes.Disconnect, Index, -1, reason, 0x0, 0f, 0f, 0f);
|
NetMessage.SendData((int)PacketTypes.Disconnect, Index, -1, reason, 0x0, 0f, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Teleport(int tileX, int tileY)
|
||||||
|
{
|
||||||
|
if (TPlayer.SpawnX >= 0 && TPlayer.SpawnY >= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int oldSpawnX = Main.spawnTileX;
|
||||||
|
int oldSpawnY = Main.spawnTileY;
|
||||||
|
Main.spawnTileX = tileX;
|
||||||
|
Main.spawnTileY = tileY;
|
||||||
|
//Send only that player the new spawn point data
|
||||||
|
NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0f, 0f, 0f);
|
||||||
|
//Force them to respawn
|
||||||
|
Spawn();
|
||||||
|
//Reset to old spawnpoint and send spawn data back to player
|
||||||
|
Main.spawnTileX = (int)oldSpawnX;
|
||||||
|
Main.spawnTileY = (int)oldSpawnY;
|
||||||
|
NetMessage.SendData((int)PacketTypes.WorldInfo, Index, -1, "", 0, 0f, 0f, 0f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Spawn()
|
||||||
|
{
|
||||||
|
NetMessage.SendData((int)PacketTypes.PlayerSpawn, Index, -1, "", Index, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SendTileSquare(int x, int y, int size = 10)
|
public virtual void SendTileSquare(int x, int y, int size = 10)
|
||||||
{
|
{
|
||||||
NetMessage.SendData((int)PacketTypes.TileSendSquare, Index, -1, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)), 0f);
|
NetMessage.SendData((int)PacketTypes.TileSendSquare, Index, -1, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)), 0f);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ 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.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
@ -29,7 +30,7 @@ using TerrariaAPI.Hooks;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
[APIVersion(1, 4)]
|
[APIVersion(1, 5)]
|
||||||
public class TShock : TerrariaPlugin
|
public class TShock : TerrariaPlugin
|
||||||
{
|
{
|
||||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
@ -256,7 +257,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
|
private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
|
||||||
{
|
{
|
||||||
if (Main.netMode != 2)
|
if (Main.netMode != 2 || e.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (msg.whoAmI != ply)
|
if (msg.whoAmI != ply)
|
||||||
|
|
@ -293,6 +294,9 @@ namespace TShockAPI
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ServerHooks_OnCommand(string text, HandledEventArgs e)
|
private void ServerHooks_OnCommand(string text, HandledEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
// Damn you ThreadStatic and Redigit
|
// Damn you ThreadStatic and Redigit
|
||||||
if (Main.rand == null)
|
if (Main.rand == null)
|
||||||
{
|
{
|
||||||
|
|
@ -335,6 +339,9 @@ namespace TShockAPI
|
||||||
|
|
||||||
private void GetData(GetDataEventArgs e)
|
private void GetData(GetDataEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (Main.netMode != 2 || e.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
PacketTypes type = e.MsgID;
|
PacketTypes type = e.MsgID;
|
||||||
TSPlayer player = Players[e.Msg.whoAmI];
|
TSPlayer player = Players[e.Msg.whoAmI];
|
||||||
|
|
||||||
|
|
@ -372,7 +379,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
private void OnGreetPlayer(int who, HandledEventArgs e)
|
private void OnGreetPlayer(int who, HandledEventArgs e)
|
||||||
{
|
{
|
||||||
if (Main.netMode != 2)
|
if (Main.netMode != 2 || e.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TSPlayer player = Players[who];
|
TSPlayer player = Players[who];
|
||||||
|
|
@ -410,27 +417,6 @@ namespace TShockAPI
|
||||||
* Useful stuff:
|
* Useful stuff:
|
||||||
* */
|
* */
|
||||||
|
|
||||||
public static void Teleport(int ply, int x, int y)
|
|
||||||
{
|
|
||||||
int oldSpawnX = Main.spawnTileX;
|
|
||||||
int oldSpawnY = Main.spawnTileY;
|
|
||||||
Main.spawnTileX = x;
|
|
||||||
Main.spawnTileY = y;
|
|
||||||
//Send only that player the new spawn point data
|
|
||||||
NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f);
|
|
||||||
//Force them to respawn
|
|
||||||
NetMessage.SendData(12, ply, -1, "", ply, 0.0f, 0.0f, 0.0f);
|
|
||||||
//Reset to old spawnpoint and send spawn data back to player
|
|
||||||
Main.spawnTileX = (int)oldSpawnX;
|
|
||||||
Main.spawnTileY = (int)oldSpawnY;
|
|
||||||
NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Teleport(int ply, float x, float y)
|
|
||||||
{
|
|
||||||
Teleport(ply, (int)x, (int)y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void StartInvasion()
|
public static void StartInvasion()
|
||||||
{
|
{
|
||||||
Main.invasionType = 1;
|
Main.invasionType = 1;
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@
|
||||||
<Reference Include="TerrariaServerAPI">
|
<Reference Include="TerrariaServerAPI">
|
||||||
<HintPath>TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
|
<HintPath>TerrariaServerBins\TerrariaServerAPI.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="XNAHelpers">
|
||||||
|
<HintPath>TerrariaServerBins\XNAHelpers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BackupManager.cs" />
|
<Compile Include="BackupManager.cs" />
|
||||||
|
|
@ -134,7 +137,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
|
||||||
Binary file not shown.
BIN
TShockAPI/TerrariaServerBins/XNAHelpers.dll
Normal file
BIN
TShockAPI/TerrariaServerBins/XNAHelpers.dll
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue