Players now in sync with server when protect spawn or anti build it on.
This commit is contained in:
parent
6411e71cee
commit
f810f5f979
1 changed files with 31 additions and 1 deletions
|
|
@ -343,13 +343,14 @@ namespace TShockAPI
|
||||||
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == 0 || type == 1)
|
if (type == 0 || type == 1 || type == 2 || type == 3)
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.disableBuild)
|
if (ConfigurationManager.disableBuild)
|
||||||
{
|
{
|
||||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||||
{
|
{
|
||||||
Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red);
|
Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red);
|
||||||
|
RevertPlayerChanges(e.Msg.whoAmI, type, x, y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -361,6 +362,7 @@ namespace TShockAPI
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red);
|
Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red);
|
||||||
|
RevertPlayerChanges(e.Msg.whoAmI, type, x, y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -376,6 +378,34 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void RevertPlayerChanges(int player, byte action, int x, int y)
|
||||||
|
{
|
||||||
|
int revertAction = 0;
|
||||||
|
float revertType = 0f;
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
revertAction = 1;
|
||||||
|
revertType = Main.tile[x, y].type;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
revertAction = 0;
|
||||||
|
revertType = 0f;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
revertAction = 3;
|
||||||
|
revertType = Main.tile[x, y].wall;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
revertAction = 2;
|
||||||
|
revertType = 0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
NetMessage.SendData(17, player, -1, "", revertAction, x, y, revertType);
|
||||||
|
for (int j = y - 2; j <= (y + 2); j++)
|
||||||
|
NetMessage.SendData(10, player, -1, "", 5, (float)(x - 2), (float)j, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
bool HandleTogglePvp(MemoryStream data, GetDataEventArgs e)
|
bool HandleTogglePvp(MemoryStream data, GetDataEventArgs e)
|
||||||
{
|
{
|
||||||
int id = data.ReadByte();
|
int id = data.ReadByte();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue