Invisibility Potions are now item banable.

New noclip detection, has ignore permission.
This commit is contained in:
Zidonuke 2011-12-27 13:26:37 -05:00
parent 40973abb3f
commit c11b944735
4 changed files with 56 additions and 6 deletions

View file

@ -195,6 +195,9 @@ namespace TShockAPI
[Description("Require all players to register or login before being allowed to play.")]
public bool RequireLogin = false;
[Description("Disables Invisibility potions from being used in PvP (Note, they can use them on the client, but the effect isn't sent to the rest of the server)")]
public bool DisableInvisPvP = false;
public static ConfigFile Read(string path)
{

View file

@ -90,6 +90,7 @@ namespace TShockAPI
{PacketTypes.NpcStrike, HandleNpcStrike},
{PacketTypes.NpcSpecial, HandleSpecial},
{PacketTypes.PlayerAnimation, HandlePlayerAnimation},
{PacketTypes.PlayerBuff, HandlePlayerBuffUpdate}
};
}
@ -624,6 +625,22 @@ namespace TShockAPI
args.Player.Spawn();
return true;
}
if(!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) && TShock.CheckPlayerCollision((int)(pos.X / 16f), (int)(pos.Y / 16f)))
{
int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
if(args.Player.Teleport(lastTileX, lastTileY))
{
args.Player.SendMessage("You got stuck in a solid object, Sent to last good position.");
}
else
{
args.Player.SendMessage("You got stuck in a solid object, Sent to spawn point.");
args.Player.Spawn();
}
return true;
}
}
args.Player.LastNetPosition = pos;
@ -1063,7 +1080,7 @@ namespace TShockAPI
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
return true;
}
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 64))
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 50))
{
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
return true;
@ -1097,7 +1114,7 @@ namespace TShockAPI
return false;
}
if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f), 64))
if (TShock.CheckRangePermission(args.Player, (int)(pos.X / 16f), (int)(pos.Y / 16f)))
{
args.Player.SendData(PacketTypes.ItemDrop, "", id);
return true;
@ -1163,7 +1180,7 @@ namespace TShockAPI
return true;
}
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 128))
if (TShock.CheckRangePermission(args.Player, TShock.Players[id].TileX, TShock.Players[id].TileY, 100))
{
args.Player.SendData(PacketTypes.PlayerHp, "", id);
args.Player.SendData(PacketTypes.PlayerUpdate, "", id);
@ -1209,7 +1226,7 @@ namespace TShockAPI
return true;
}
if (TShock.Config.RangeChecks && ((Math.Abs(args.Player.TileX - (Main.npc[id].position.X / 16f)) > 128) || (Math.Abs(args.Player.TileY - (Main.npc[id].position.Y / 16f)) > 128)))
if (TShock.Config.RangeChecks && TShock.CheckRangePermission(args.Player, (int)(Main.npc[id].position.X / 16f), (int)(Main.npc[id].position.Y / 16f), 100))
{
args.Player.SendData(PacketTypes.NpcUpdate, "", id);
return true;
@ -1255,5 +1272,33 @@ namespace TShockAPI
return false;
}
private static bool HandlePlayerBuffUpdate(GetDataHandlerArgs args)
{
var id = args.Data.ReadInt8();
for (int i = 0; i < 10; i++)
{
var buff = args.Data.ReadInt8();
if (buff == 10)
{
if (!args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned("Invisibility Potion"))
buff = 0;
else if (TShock.Config.DisableInvisPvP && args.TPlayer.hostile)
buff = 0;
}
args.TPlayer.buffType[i] = buff;
if (args.TPlayer.buffType[i] > 0)
{
args.TPlayer.buffTime[i] = 60;
}
else
{
args.TPlayer.buffTime[i] = 0;
}
}
return true;
}
}
}

View file

@ -38,6 +38,9 @@ namespace TShockAPI
[Description("Prevents you from being reverted by place tile abuse detection")]
public static readonly string ignoreplacetiledetection;
[Description("Prevents you from being reverted by no clip detection")]
public static readonly string ignorenoclipdetection;
[Description("Specific log messages are sent to users with this permission")]
public static readonly string logs;

View file

@ -755,8 +755,7 @@ namespace TShockAPI
if (Config.RememberLeavePos)
{
var pos = RememberedPos.GetLeavePos(player.Name, player.IP);
player.Teleport((int)pos.X, (int)pos.Y);
player.SendTileSquare((int)pos.X, (int)pos.Y);
player.Teleport((int) pos.X, (int) pos.Y);
}
e.Handled = true;
}