Begin Raptor compatibility
This commit is contained in:
parent
c54f7bd850
commit
3e9aee3414
9 changed files with 431 additions and 46 deletions
|
|
@ -3017,6 +3017,12 @@ namespace TShockAPI
|
|||
args.Player.TempPoints[0] = Point.Zero;
|
||||
args.Player.TempPoints[1] = Point.Zero;
|
||||
args.Player.SendMessage("Set region " + regionName, Color.Yellow);
|
||||
|
||||
foreach (TSPlayer tsplr in TShock.Players)
|
||||
{
|
||||
if (tsplr.IsRaptor && tsplr.Group.HasPermission(Permissions.manageregion))
|
||||
tsplr.SendRaptorRegion(TShock.Regions.GetRegionByName(regionName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3064,19 +3070,26 @@ namespace TShockAPI
|
|||
{
|
||||
string regionName = String.Join(" ", args.Parameters.GetRange(1, args.Parameters.Count - 1));
|
||||
if (TShock.Regions.DeleteRegion(regionName))
|
||||
args.Player.SendMessage("Deleted region " + regionName, Color.Yellow);
|
||||
else
|
||||
args.Player.SendMessage("Could not find specified region", Color.Red);
|
||||
{
|
||||
args.Player.SendInfoMessage("Deleted region \"{0}\".", regionName);
|
||||
foreach (TSPlayer tsplr in TShock.Players)
|
||||
{
|
||||
if (tsplr.IsRaptor && tsplr.Group.HasPermission(Permissions.manageregion))
|
||||
tsplr.SendRaptorRegionDelete(TShock.Regions.GetRegionByName(regionName));
|
||||
}
|
||||
}
|
||||
else
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /region delete <name>", Color.Red);
|
||||
args.Player.SendErrorMessage("Could not find the specified region!");
|
||||
}
|
||||
else
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region delete <name>");
|
||||
break;
|
||||
}
|
||||
case "clear":
|
||||
{
|
||||
args.Player.TempPoints[0] = Point.Zero;
|
||||
args.Player.TempPoints[1] = Point.Zero;
|
||||
args.Player.SendMessage("Cleared temp area", Color.Yellow);
|
||||
args.Player.SendInfoMessage("Cleared temporary points.");
|
||||
args.Player.AwaitingTempPoint = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -3415,19 +3428,18 @@ namespace TShockAPI
|
|||
if (TShock.Regions.resizeRegion(args.Parameters[1], addAmount, direction))
|
||||
{
|
||||
args.Player.SendMessage("Region Resized Successfully!", Color.Yellow);
|
||||
foreach (TSPlayer tsplr in TShock.Players)
|
||||
{
|
||||
if (tsplr.IsRaptor && tsplr.Group.HasPermission(Permissions.manageregion))
|
||||
tsplr.SendRaptorRegion(TShock.Regions.GetRegionByName(args.Parameters[1]));
|
||||
}
|
||||
TShock.Regions.ReloadAllRegions();
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /region resize <region> <u/d/l/r> <amount>",
|
||||
Color.Red);
|
||||
}
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region resize <region> <u/d/l/r> <amount>");
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /region resize <region> <u/d/l/r> <amount>",
|
||||
Color.Red);
|
||||
}
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /region resize <region> <u/d/l/r> <amount>");
|
||||
break;
|
||||
}
|
||||
case "tp":
|
||||
|
|
@ -3452,7 +3464,6 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
args.Player.Teleport(region.Area.Center.X * 16, region.Area.Center.Y * 16);
|
||||
|
||||
break;
|
||||
}
|
||||
case "help":
|
||||
|
|
|
|||
|
|
@ -419,6 +419,51 @@ namespace TShockAPI.DB
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position of a region.
|
||||
/// </summary>
|
||||
/// <param name="regionName">The region name.</param>
|
||||
/// <param name="x">The X position.</param>
|
||||
/// <param name="y">The Y position.</param>
|
||||
/// <param name="height">The height.</param>
|
||||
/// <param name="width">The width.</param>
|
||||
/// <returns>Whether the operation succeeded.</returns>
|
||||
public bool PositionRegion(string regionName, int x, int y, int width, int height)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (database.Query("UPDATE Regions SET X1 = @0, Y1 = @1, width = @2, height = @3 WHERE RegionName = @4 AND WorldID = @5",
|
||||
x, y, width, height, regionName, Main.worldID.ToString()) > 0)
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Offsets a region.
|
||||
/// </summary>
|
||||
/// <param name="regionName">The region name.</param>
|
||||
/// <param name="x">The X offset.</param>
|
||||
/// <param name="y">The Y offset.</param>
|
||||
/// <returns>Whether the operation succeeded.</returns>
|
||||
public bool OffsetRegion(string regionName, int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (database.Query("UPDATE Regions SET X1 = X1 + @0, Y1 = Y1 + @1 WHERE RegionName = @2 AND WorldID = @3",
|
||||
x, y, regionName, Main.worldID.ToString()) > 0)
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the regions names from world
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ namespace TShockAPI.DB
|
|||
public class WarpManager
|
||||
{
|
||||
private IDbConnection database;
|
||||
/// <summary>
|
||||
/// The list of warps.
|
||||
/// </summary>
|
||||
public List<Warp> Warps;
|
||||
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
|
||||
public WarpManager(IDbConnection db)
|
||||
|
|
@ -53,6 +57,7 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
database.Query("INSERT INTO Warps (X, Y, WarpName, WorldID) VALUES (@0, @1, @2, @3);", x, y, name, worldid);
|
||||
Warps.Add(new Warp(new Vector2(x, y), name, worldid, "0"));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -67,6 +72,7 @@ namespace TShockAPI.DB
|
|||
try
|
||||
{
|
||||
database.Query("DELETE FROM Warps WHERE WarpName=@0 AND WorldID=@1", name, Main.worldID.ToString());
|
||||
Warps.RemoveAll(w => w.WarpName == name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -116,21 +122,12 @@ namespace TShockAPI.DB
|
|||
var warps = new List<Warp>();
|
||||
try
|
||||
{
|
||||
using (var reader = database.QueryReader("SELECT * FROM Warps WHERE WorldID=@0", worldid))
|
||||
using (var reader = database.QueryReader("SELECT * FROM Warps WHERE Private = @0 AND WorldID = @1",
|
||||
"0", worldid))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (reader.Get<String>("Private") == "0" || reader.Get<String>("Private") == null)
|
||||
warps.Add(new Warp {WarpName = reader.Get<string>("WarpName")});
|
||||
}
|
||||
catch
|
||||
{
|
||||
warps.Add(new Warp {WarpName = reader.Get<string>("WarpName")});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -140,25 +137,52 @@ namespace TShockAPI.DB
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the warps names from world
|
||||
/// Sets the position of a warp.
|
||||
/// </summary>
|
||||
/// <param name="worldid">World name to get warps from</param>
|
||||
/// <returns>List of warps with only their names</returns>
|
||||
public bool HideWarp(string warp, bool state)
|
||||
/// <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>
|
||||
public bool PositionWarp(string warpName, int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
string query = "UPDATE Warps SET Private=@0 WHERE WarpName=@1 AND WorldID=@2";
|
||||
|
||||
database.Query(query, state ? "1" : "0", warp, Main.worldID.ToString());
|
||||
|
||||
if (database.Query("UPDATE Warps SET X = @0, Y = @1 WHERE WarpName = @2 AND WorldID = @3",
|
||||
x, y, warpName, Main.worldID.ToString()) > 0)
|
||||
{
|
||||
Warps.Find(w => w.WarpName == warpName).WarpPos = new Vector2(x, y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the hidden state of a warp.
|
||||
/// </summary>
|
||||
/// <param name="warpName">The warp name.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <returns>Whether the operation suceeded.</returns>
|
||||
public bool HideWarp(string warpName, bool state)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (database.Query("UPDATE Warps SET Private = @0 WHERE WarpName = @1 AND WorldID = @2",
|
||||
state ? "1" : "0", warpName, Main.worldID.ToString()) > 0)
|
||||
{
|
||||
Warps.Find(w => w.WarpName == warpName).Private = state ? "1" : "0";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1234,7 +1234,8 @@ namespace TShockAPI
|
|||
{PacketTypes.SpawnBossorInvasion, HandleSpawnBoss},
|
||||
{PacketTypes.Teleport, HandleTeleport},
|
||||
{PacketTypes.PaintTile, HandlePaintTile},
|
||||
{PacketTypes.PaintWall, HandlePaintWall}
|
||||
{PacketTypes.PaintWall, HandlePaintWall},
|
||||
{PacketTypes.Placeholder, HandleRaptor}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -3390,5 +3391,77 @@ namespace TShockAPI
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool HandleRaptor(GetDataHandlerArgs args)
|
||||
{
|
||||
var type = (RaptorPacketTypes)args.Data.ReadInt8();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RaptorPacketTypes.Acknowledge:
|
||||
args.Player.IsRaptor = true;
|
||||
return true;
|
||||
case RaptorPacketTypes.Region:
|
||||
if (args.Player.Group.HasPermission(Permissions.manageregion))
|
||||
{
|
||||
int x = args.Data.ReadInt32();
|
||||
int y = args.Data.ReadInt32();
|
||||
int width = args.Data.ReadInt32();
|
||||
int height = args.Data.ReadInt32();
|
||||
string regionName = args.Data.ReadString();
|
||||
|
||||
if (TShock.Regions.GetRegionByName(regionName).Area == Rectangle.Empty)
|
||||
{
|
||||
TShock.Regions.AddRegion(x, y, width, height, regionName, args.Player.UserAccountName, Main.worldID.ToString());
|
||||
Log.Info("{0} added region \"{1}\".", args.Player.UserAccountName, regionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
TShock.Regions.PositionRegion(regionName, x, y, width, height);
|
||||
Log.Info("{0} moved region \"{1}\".", args.Player.UserAccountName, regionName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case RaptorPacketTypes.RegionDelete:
|
||||
if (args.Player.Group.HasPermission(Permissions.manageregion))
|
||||
{
|
||||
string regionName = args.Data.ReadString();
|
||||
TShock.Regions.DeleteRegion(regionName);
|
||||
Log.Info("{0} deleted region \"{1}\".", args.Player.UserAccountName, regionName);
|
||||
}
|
||||
return true;
|
||||
case RaptorPacketTypes.Warp:
|
||||
if (args.Player.Group.HasPermission(Permissions.managewarp))
|
||||
{
|
||||
int x = (int)args.Data.ReadSingle();
|
||||
int y = (int)args.Data.ReadSingle();
|
||||
bool isHidden = args.Data.ReadBoolean();
|
||||
string warpName = args.Data.ReadString();
|
||||
|
||||
Warp warp = TShock.Warps.FindWarp(warpName);
|
||||
if (warp.WarpPos == Vector2.Zero)
|
||||
{
|
||||
TShock.Warps.AddWarp(x, y, warpName, Main.worldID.ToString());
|
||||
Log.Info("{0} added warp \"{1}\".", args.Player.UserAccountName, warpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
TShock.Warps.PositionWarp(warpName, x, y);
|
||||
Log.Info("{0} moved warp \"{1}\".", args.Player.UserAccountName, warpName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case RaptorPacketTypes.WarpDelete:
|
||||
if (args.Player.Group.HasPermission(Permissions.managewarp))
|
||||
{
|
||||
string warpName = args.Data.ReadString();
|
||||
TShock.Warps.RemoveWarp(warpName);
|
||||
Log.Info("{0} deleted warp \"{1}\".", args.Player.UserAccountName, warpName);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace TShockAPI.Hooks
|
|||
|
||||
public static void OnPlayerPostLogin(TSPlayer ply)
|
||||
{
|
||||
if(PlayerPostLogin == null)
|
||||
if (PlayerPostLogin == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
38
TShockAPI/RaptorPacketTypes.cs
Normal file
38
TShockAPI/RaptorPacketTypes.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom packet types for use with Raptor.
|
||||
/// </summary>
|
||||
public enum RaptorPacketTypes : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// The packet sent to the server to be acknowledged as a Raptor client.
|
||||
/// </summary>
|
||||
Acknowledge = 0,
|
||||
/// <summary>
|
||||
/// The packet sent to the client which dictates its permissions.
|
||||
/// </summary>
|
||||
Permissions,
|
||||
/// <summary>
|
||||
/// The packet sent which sets region info.
|
||||
/// </summary>
|
||||
Region,
|
||||
/// <summary>
|
||||
/// The packet sent to delete a region.
|
||||
/// </summary>
|
||||
RegionDelete,
|
||||
/// <summary>
|
||||
/// The packet sent which sets warp info.
|
||||
/// </summary>
|
||||
Warp,
|
||||
/// <summary>
|
||||
/// The packet sent to delete a warp.
|
||||
/// </summary>
|
||||
WarpDelete
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,10 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Terraria;
|
||||
using TShockAPI.DB;
|
||||
using TShockAPI.Net;
|
||||
|
||||
namespace TShockAPI
|
||||
|
|
@ -38,6 +40,11 @@ namespace TShockAPI
|
|||
/// </summary>
|
||||
public static readonly TSPlayer All = new TSPlayer("All");
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the player is using Raptor.
|
||||
/// </summary>
|
||||
public bool IsRaptor { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amount of tiles that the player has killed in the last second.
|
||||
/// </summary>
|
||||
|
|
@ -882,6 +889,178 @@ namespace TShockAPI
|
|||
return TShock.SendBytes(Netplay.serverSock[Index], data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends Raptor permissions to the player.
|
||||
/// </summary>
|
||||
public void SendRaptorPermissions()
|
||||
{
|
||||
if (!IsRaptor)
|
||||
return;
|
||||
|
||||
lock (NetMessage.buffer[Index].writeBuffer)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
|
||||
{
|
||||
using (var writer = new BinaryWriter(ms))
|
||||
{
|
||||
writer.BaseStream.Position = 4;
|
||||
|
||||
writer.Write((byte)PacketTypes.Placeholder);
|
||||
writer.Write((byte)RaptorPacketTypes.Permissions);
|
||||
|
||||
writer.Write(String.Join(",", Group.TotalPermissions.ToArray()));
|
||||
|
||||
length = (int)writer.BaseStream.Position;
|
||||
writer.BaseStream.Position = 0;
|
||||
writer.Write(length - 4);
|
||||
}
|
||||
}
|
||||
|
||||
TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sends a region to the player.
|
||||
/// <param name="region">The region.</param>
|
||||
/// </summary>
|
||||
public void SendRaptorRegion(Region region)
|
||||
{
|
||||
if (!IsRaptor)
|
||||
return;
|
||||
|
||||
lock (NetMessage.buffer[Index].writeBuffer)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
|
||||
{
|
||||
using (var writer = new BinaryWriter(ms))
|
||||
{
|
||||
writer.BaseStream.Position = 4;
|
||||
|
||||
writer.Write((byte)PacketTypes.Placeholder);
|
||||
writer.Write((byte)RaptorPacketTypes.Region);
|
||||
|
||||
writer.Write(region.Area.X);
|
||||
writer.Write(region.Area.Y);
|
||||
writer.Write(region.Area.Width);
|
||||
writer.Write(region.Area.Height);
|
||||
writer.Write(region.Name);
|
||||
|
||||
length = (int)writer.BaseStream.Position;
|
||||
writer.BaseStream.Position = 0;
|
||||
writer.Write(length - 4);
|
||||
}
|
||||
}
|
||||
|
||||
TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sends a region deletion to the player.
|
||||
/// <param name="region">The region.</param>
|
||||
/// </summary>
|
||||
public void SendRaptorRegionDelete(Region region)
|
||||
{
|
||||
if (!IsRaptor)
|
||||
return;
|
||||
|
||||
lock (NetMessage.buffer[Index].writeBuffer)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
|
||||
{
|
||||
using (var writer = new BinaryWriter(ms))
|
||||
{
|
||||
writer.BaseStream.Position = 4;
|
||||
|
||||
writer.Write((byte)PacketTypes.Placeholder);
|
||||
writer.Write((byte)RaptorPacketTypes.RegionDelete);
|
||||
|
||||
writer.Write(region.Name);
|
||||
|
||||
length = (int)writer.BaseStream.Position;
|
||||
writer.BaseStream.Position = 0;
|
||||
writer.Write(length - 4);
|
||||
}
|
||||
}
|
||||
|
||||
TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sends a warp to the player.
|
||||
/// <param name="warp">The warp.</param>
|
||||
/// </summary>
|
||||
public void SendRaptorWarp(Warp warp)
|
||||
{
|
||||
if (!IsRaptor)
|
||||
return;
|
||||
|
||||
lock (NetMessage.buffer[Index].writeBuffer)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
|
||||
{
|
||||
using (var writer = new BinaryWriter(ms))
|
||||
{
|
||||
writer.BaseStream.Position = 4;
|
||||
|
||||
writer.Write((byte)PacketTypes.Placeholder);
|
||||
writer.Write((byte)RaptorPacketTypes.Warp);
|
||||
|
||||
writer.Write(warp.WarpPos.X);
|
||||
writer.Write(warp.WarpPos.Y);
|
||||
writer.Write(warp.Private != "0");
|
||||
writer.Write(warp.WarpName);
|
||||
|
||||
length = (int)writer.BaseStream.Position;
|
||||
writer.BaseStream.Position = 0;
|
||||
writer.Write(length - 4);
|
||||
}
|
||||
}
|
||||
|
||||
TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sends a warp deletion to the player.
|
||||
/// <param name="warp">The warp.</param>
|
||||
/// </summary>
|
||||
public void SendRaptorWarpDeletion(Warp warp)
|
||||
{
|
||||
if (!IsRaptor)
|
||||
return;
|
||||
|
||||
lock (NetMessage.buffer[Index].writeBuffer)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
using (var ms = new MemoryStream(NetMessage.buffer[Index].writeBuffer, true))
|
||||
{
|
||||
using (var writer = new BinaryWriter(ms))
|
||||
{
|
||||
writer.BaseStream.Position = 4;
|
||||
|
||||
writer.Write((byte)PacketTypes.Placeholder);
|
||||
writer.Write((byte)RaptorPacketTypes.WarpDelete);
|
||||
|
||||
writer.Write(warp.WarpName);
|
||||
|
||||
length = (int)writer.BaseStream.Position;
|
||||
writer.BaseStream.Position = 0;
|
||||
writer.Write(length - 4);
|
||||
}
|
||||
}
|
||||
|
||||
TShock.PacketBuffer.SendBytes(Netplay.serverSock[Index], NetMessage.buffer[Index].writeBuffer, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a command callback to a specified command string.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ using Terraria;
|
|||
using TerrariaApi.Server;
|
||||
using TShockAPI.DB;
|
||||
using TShockAPI.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -346,6 +348,24 @@ namespace TShockAPI
|
|||
|
||||
private void OnPlayerLogin(Hooks.PlayerPostLoginEventArgs args)
|
||||
{
|
||||
if (args.Player.IsRaptor)
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
args.Player.SendRaptorPermissions();
|
||||
if (args.Player.Group.HasPermission(Permissions.manageregion))
|
||||
{
|
||||
for (int i = 0; i < Regions.Regions.Count; i++)
|
||||
args.Player.SendRaptorRegion(Regions.Regions[i]);
|
||||
}
|
||||
if (args.Player.Group.HasPermission(Permissions.managewarp))
|
||||
{
|
||||
for (int i = 0; i < Warps.Warps.Count; i++)
|
||||
args.Player.SendRaptorWarp(Warps.Warps[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
User u = Users.GetUserByName(args.Player.UserAccountName);
|
||||
List<String> KnownIps = new List<string>();
|
||||
if (!string.IsNullOrWhiteSpace(u.KnownIps))
|
||||
|
|
@ -1090,13 +1110,7 @@ namespace TShockAPI
|
|||
Debug.WriteLine("Recv: {0:X}: {2} ({1:XX})", e.Msg.whoAmI, (byte) type, type);
|
||||
|
||||
var player = Players[e.Msg.whoAmI];
|
||||
if (player == null)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.ConnectionAlive)
|
||||
if (player == null || !player.ConnectionAlive)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
|
|
@ -1109,7 +1123,7 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
if ((player.State < 10 || player.Dead) && (int) type > 12 && (int) type != 16 && (int) type != 42 && (int) type != 50 &&
|
||||
(int) type != 38 && (int) type != 21)
|
||||
(int) type != 38 && (int) type != 21 && (int) type != 67)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
<Compile Include="Hooks\GeneralHooks.cs" />
|
||||
<Compile Include="Hooks\PlayerHooks.cs" />
|
||||
<Compile Include="PaginationTools.cs" />
|
||||
<Compile Include="RaptorPacketTypes.cs" />
|
||||
<Compile Include="Rest\RestPermissions.cs" />
|
||||
<Compile Include="SaveManager.cs" />
|
||||
<Compile Include="DB\BanManager.cs" />
|
||||
|
|
@ -176,7 +177,7 @@
|
|||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<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>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue