Add permissions for spawning bosses/starting invasions

This commit is contained in:
Deathmax 2012-01-18 19:50:49 +08:00
parent 44408a25d6
commit 27f61645ce
2 changed files with 42 additions and 4 deletions

View file

@ -699,7 +699,8 @@ namespace TShockAPI
{PacketTypes.PlayerBuff, HandlePlayerBuffUpdate}, {PacketTypes.PlayerBuff, HandlePlayerBuffUpdate},
{PacketTypes.PasswordSend, HandlePassword}, {PacketTypes.PasswordSend, HandlePassword},
{PacketTypes.ContinueConnecting2, HandleConnecting}, {PacketTypes.ContinueConnecting2, HandleConnecting},
{PacketTypes.ProjectileDestroy, HandleProjectileKill} {PacketTypes.ProjectileDestroy, HandleProjectileKill},
{PacketTypes.SpawnBossorInvasion, HandleSpawnBoss}
}; };
} }
@ -2192,6 +2193,40 @@ namespace TShockAPI
return true; 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;
}
} }
} }

View file

@ -149,8 +149,11 @@ namespace TShockAPI
[Description("Allow unrestricted Send Tile Square usage, for client side world editing")] public static readonly [Description("Allow unrestricted Send Tile Square usage, for client side world editing")] public static readonly
string allowclientsideworldedit; string allowclientsideworldedit;
[Description("User can execute Lua files from the hard disk and run Lua strings.")] public static readonly string [Description("User can summon bosses using items")]
runlua; public static readonly string summonboss;
[Description("User can start invasions (Goblin/Snow Legion) using items")]
public static readonly string startinvasion;
static Permissions() static Permissions()
{ {