Merge commit '767268e1f7'
This commit is contained in:
commit
7dbcf73f00
4 changed files with 62 additions and 4 deletions
|
|
@ -55,6 +55,7 @@ namespace TShockAPI
|
|||
TShock.admincommandList.Add("help", new CommandDelegate(Help));
|
||||
TShock.admincommandList.Add("slap", new CommandDelegate(Slap));
|
||||
TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave));
|
||||
TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn));
|
||||
TShock.commandList.Add("help", new CommandDelegate(Help));
|
||||
TShock.commandList.Add("kill", new CommandDelegate(Kill));
|
||||
}
|
||||
|
|
@ -559,6 +560,12 @@ namespace TShockAPI
|
|||
else
|
||||
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]", new float[] { 255f, 0f, 0f });
|
||||
}
|
||||
|
||||
public static void ProtectSpawn(CommandArgs args)
|
||||
{
|
||||
ConfigurationManager.spawnProtect = (ConfigurationManager.spawnProtect == false);
|
||||
Tools.SendMessage(args.PlayerID, "Spawn is now " + (ConfigurationManager.spawnProtect ? "protected" : "open") + ".");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,7 @@ namespace TShockAPI
|
|||
public bool KickKillTileAbusers = false;
|
||||
public bool BanExplosives = true;
|
||||
public bool KickExplosives = true;
|
||||
public bool SpawnProtection = true;
|
||||
public int SpawnProtectionRadius = 5;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ namespace TShockAPI
|
|||
public static bool kickTnt = false;
|
||||
public static bool banBoom = true;
|
||||
public static bool kickBoom = true;
|
||||
public static bool spawnProtect = true;
|
||||
public static int spawnProtectRadius = 5;
|
||||
|
||||
public enum NPCList : int
|
||||
{
|
||||
|
|
@ -58,6 +60,8 @@ namespace TShockAPI
|
|||
kickTnt = cfg.KickKillTileAbusers;
|
||||
banBoom = cfg.BanExplosives;
|
||||
kickBoom = cfg.KickExplosives;
|
||||
spawnProtect = cfg.SpawnProtection;
|
||||
spawnProtectRadius = cfg.SpawnProtectionRadius;
|
||||
}
|
||||
|
||||
public static void WriteJsonConfiguration()
|
||||
|
|
@ -87,6 +91,8 @@ namespace TShockAPI
|
|||
cfg.KickKillTileAbusers = true;
|
||||
cfg.BanExplosives = true;
|
||||
cfg.KickExplosives = true;
|
||||
cfg.SpawnProtection = true;
|
||||
cfg.SpawnProtectionRadius = 5;
|
||||
|
||||
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
||||
TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
|
||||
|
|
|
|||
|
|
@ -137,8 +137,6 @@ namespace TShockAPI
|
|||
NetHooks.OnPreGetData -= GetData;
|
||||
NetHooks.OnGreetPlayer -= new NetHooks.GreetPlayerD(OnGreetPlayer);
|
||||
NpcHooks.OnStrikeNpc -= new NpcHooks.StrikeNpcD(NpcHooks_OnStrikeNpc);
|
||||
ConfigurationManager.WriteJsonConfiguration();
|
||||
Log.Info("Shutting down...");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -178,10 +176,20 @@ namespace TShockAPI
|
|||
int y = br.ReadInt32();
|
||||
byte typetile = br.ReadByte();
|
||||
|
||||
if (type == 0 || type == 1)
|
||||
if (ConfigurationManager.spawnProtect)
|
||||
if (!players[e.Msg.whoAmI].IsAdmin())
|
||||
{
|
||||
var flag = CheckSpawn(x, y);
|
||||
if (flag)
|
||||
{
|
||||
Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f });
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active)
|
||||
{
|
||||
players[e.Msg.whoAmI].tileThreshold++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -332,6 +340,30 @@ namespace TShockAPI
|
|||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else if (e.MsgID == 0x30)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
byte liquid;
|
||||
bool lava;
|
||||
using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
|
||||
{
|
||||
x = br.ReadInt32();
|
||||
y = br.ReadInt32();
|
||||
liquid = br.ReadByte();
|
||||
lava = br.ReadBoolean();
|
||||
}
|
||||
if (ConfigurationManager.spawnProtect)
|
||||
if (!players[e.Msg.whoAmI].IsAdmin())
|
||||
{
|
||||
var flag = CheckSpawn(x, y);
|
||||
if (flag)
|
||||
{
|
||||
Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f });
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -683,5 +715,16 @@ namespace TShockAPI
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckSpawn(int x, int y)
|
||||
{
|
||||
Vector2 tile = new Vector2((float)x, (float)y);
|
||||
Vector2 spawn = new Vector2((float)Main.spawnTileX, (float)Main.spawnTileY);
|
||||
var distance = Vector2.Distance(spawn, tile);
|
||||
if (distance > (float)ConfigurationManager.spawnProtectRadius)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue