Teleport handler now handles wormhole potions.
Added a permission to use wormhole potions
This commit is contained in:
parent
e044dfaf52
commit
9d55122da8
2 changed files with 38 additions and 17 deletions
|
|
@ -3564,40 +3564,58 @@ namespace TShockAPI
|
||||||
|
|
||||||
private static bool HandleTeleport(GetDataHandlerArgs args)
|
private static bool HandleTeleport(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var flag = (BitsByte)args.Data.ReadInt8();
|
BitsByte flag = (BitsByte)args.Data.ReadByte();
|
||||||
var id = args.Data.ReadInt16();
|
short id = args.Data.ReadInt16();
|
||||||
var x = args.Data.ReadSingle();
|
var x = args.Data.ReadSingle();
|
||||||
var y = args.Data.ReadSingle();
|
var y = args.Data.ReadSingle();
|
||||||
|
|
||||||
if (OnTeleport(id, flag, x, y))
|
if (OnTeleport(id, flag, x, y))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
int type = 0;
|
||||||
byte style = 0;
|
byte style = 0;
|
||||||
var isNPC = false || (flag & 1) == 1;
|
bool isNPC = type == 1;
|
||||||
|
|
||||||
if ((flag & 2) != 2)
|
if (flag[0])
|
||||||
{
|
{
|
||||||
if ((flag & 4) == 4)
|
type = 1;
|
||||||
|
}
|
||||||
|
if (flag[1])
|
||||||
|
{
|
||||||
|
type = 2;
|
||||||
|
}
|
||||||
|
if (flag[2])
|
||||||
{
|
{
|
||||||
style++;
|
style++;
|
||||||
}
|
}
|
||||||
|
if (flag[3])
|
||||||
if ((flag & 8) == 8)
|
|
||||||
{
|
{
|
||||||
style++;
|
style += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id > (isNPC ? 200 : 255))
|
//Rod of Discord teleport (usually (may be used by modded clients to teleport))
|
||||||
|
if (type == 0 && !args.Player.Group.HasPermission(Permissions.rod))
|
||||||
|
{
|
||||||
|
args.Player.SendErrorMessage("You do not have permission to teleport.");
|
||||||
|
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//NPC teleport
|
||||||
|
if (type == 1 && id >= Main.maxNPCs)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Player to player teleport (wormhole potion, usually (may be used by modded clients to teleport))
|
||||||
|
if (type == 2)
|
||||||
|
{
|
||||||
if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null)
|
if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNPC && !args.Player.Group.HasPermission(Permissions.rod))
|
if (!args.Player.Group.HasPermission(Permissions.wormhole))
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("You do not have permission to teleport.");
|
args.Player.SendErrorMessage("You do not have permission to teleport.");
|
||||||
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
|
args.Player.Teleport(args.TPlayer.position.X, args.TPlayer.position.Y);
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,9 @@ namespace TShockAPI
|
||||||
[Description("User can use the Rod of Discor.")]
|
[Description("User can use the Rod of Discor.")]
|
||||||
public static readonly string rod = "tshock.tp.rod";
|
public static readonly string rod = "tshock.tp.rod";
|
||||||
|
|
||||||
|
[Description("User can use wormhole potions.")]
|
||||||
|
public static readonly string wormhole = "tshock.tp.wormhole";
|
||||||
|
|
||||||
// tshock.world nodes
|
// tshock.world nodes
|
||||||
|
|
||||||
[Description("User can change expert state.")]
|
[Description("User can change expert state.")]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue