From 27f61645ce0b8af01d9c801f786c6840e5450b34 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Wed, 18 Jan 2012 19:50:49 +0800 Subject: [PATCH] Add permissions for spawning bosses/starting invasions --- TShockAPI/GetDataHandlers.cs | 39 ++++++++++++++++++++++++++++++++++-- TShockAPI/Permissions.cs | 7 +++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 9763a7e9..e8d3de8c 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -699,7 +699,8 @@ namespace TShockAPI {PacketTypes.PlayerBuff, HandlePlayerBuffUpdate}, {PacketTypes.PasswordSend, HandlePassword}, {PacketTypes.ContinueConnecting2, HandleConnecting}, - {PacketTypes.ProjectileDestroy, HandleProjectileKill} + {PacketTypes.ProjectileDestroy, HandleProjectileKill}, + {PacketTypes.SpawnBossorInvasion, HandleSpawnBoss} }; } @@ -2192,6 +2193,40 @@ namespace TShockAPI return true; } - + private static bool HandleSpawnBoss(GetDataHandlerArgs args) + { + var spawnboss = false; + var invasion = -1; + var plr = args.Data.ReadInt32(); + var Type = args.Data.ReadInt32(); + spawnboss = (Type == 4 || Type == 13 || (Type == 50 || Type == 125) || (Type == 126 || Type == 134 || (Type == (int) sbyte.MaxValue || Type == 128))); + if (!spawnboss) + { + switch (Type) + { + case -1: + invasion = 1; + break; + case -2: + invasion = 2; + break; + } + } + if (spawnboss && !args.Player.Group.HasPermission(Permissions.summonboss)) + { + args.Player.SendMessage("You don't have permission to summon a boss.", Color.Red); + return true; + } + if (invasion != -1 && !args.Player.Group.HasPermission(Permissions.startinvasion)) + { + args.Player.SendMessage("You don't have permission to start an invasion.", Color.Red); + return true; + } + if (!spawnboss && invasion == -1) + return true; + if (plr != args.Player.Index) + return true; + return false; + } } } \ No newline at end of file diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index d6680470..93df1ca0 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -149,8 +149,11 @@ namespace TShockAPI [Description("Allow unrestricted Send Tile Square usage, for client side world editing")] public static readonly string allowclientsideworldedit; - [Description("User can execute Lua files from the hard disk and run Lua strings.")] public static readonly string - runlua; + [Description("User can summon bosses using items")] + public static readonly string summonboss; + + [Description("User can start invasions (Goblin/Snow Legion) using items")] + public static readonly string startinvasion; static Permissions() {