require an extra perm for changing bots

This commit is contained in:
UnknownShadow200 2016-11-30 22:14:58 +11:00
parent fa817a7c8b
commit 39a2c83da4
5 changed files with 39 additions and 31 deletions

View File

@ -25,7 +25,8 @@ namespace MCGalaxy.Commands.CPE {
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public override CommandPerm[] ExtraPerms { public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the model of others") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the model of others"),
new CommandPerm(LevelPermission.Operator, "+ can change the model of bots") }; }
} }
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("xmodel", "-own") }; } get { return new[] { new CommandAlias("xmodel", "-own") }; }
@ -40,11 +41,6 @@ namespace MCGalaxy.Commands.CPE {
} }
protected override void SetBotData(Player p, PlayerBot bot, string[] args) { protected override void SetBotData(Player p, PlayerBot bot, string[] args) {
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
Player.Message(p, "Hence, you cannot the model of that bot.");
return;
}
string model = GetModel(p, args, 2); string model = GetModel(p, args, 2);
bot.model = model; bot.model = model;
Entities.UpdateModel(bot.id, model, bot.level, null); Entities.UpdateModel(bot.id, model, bot.level, null);

View File

@ -25,7 +25,8 @@ namespace MCGalaxy.Commands.CPE {
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override CommandPerm[] ExtraPerms { public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the skin of others") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the skin of others"),
new CommandPerm(LevelPermission.Operator, "+ can change the skin of bots") }; }
} }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
@ -37,11 +38,6 @@ namespace MCGalaxy.Commands.CPE {
} }
protected override void SetBotData(Player p, PlayerBot bot, string[] args) { protected override void SetBotData(Player p, PlayerBot bot, string[] args) {
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
Player.Message(p, "Hence, you cannot the skin of that bot.");
return;
}
string skin = GetSkin(p, args, 2, bot.name); string skin = GetSkin(p, args, 2, bot.name);
if (skin == null) return; if (skin == null) return;
bot.SkinName = skin; bot.SkinName = skin;

View File

@ -25,7 +25,8 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Chat; } } public override string type { get { return CommandTypes.Chat; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override CommandPerm[] ExtraPerms { public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the color of others") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the color of others"),
new CommandPerm(LevelPermission.Operator, "+ can change the color of bots") }; }
} }
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("colour"), new CommandAlias("xcolor", "-own") }; } get { return new[] { new CommandAlias("colour"), new CommandAlias("xcolor", "-own") }; }
@ -33,6 +34,11 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) { UseBotOrPlayer(p, message, "color"); } public override void Use(Player p, string message) { UseBotOrPlayer(p, message, "color"); }
protected override void SetBotData(Player p, PlayerBot bot, string[] args) { protected override void SetBotData(Player p, PlayerBot bot, string[] args) {
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
Player.Message(p, "Hence, you cannot change the color of that bot.");
return;
}
string color = args.Length > 2 ? Colors.Parse(args[2]) : "&1"; string color = args.Length > 2 ? Colors.Parse(args[2]) : "&1";
if (color == "") { Player.Message(p, "There is no color \"" + args[2] + "\"."); return; } if (color == "") { Player.Message(p, "There is no color \"" + args[2] + "\"."); return; }
Chat.MessageLevel(bot.level, "Bot " + bot.ColoredName + "'s %Scolor was set to " Chat.MessageLevel(bot.level, "Bot " + bot.ColoredName + "'s %Scolor was set to "

View File

@ -26,7 +26,8 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Chat; } } public override string type { get { return CommandTypes.Chat; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override CommandPerm[] ExtraPerms { public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the nick of other players") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can change the nick of others"),
new CommandPerm(LevelPermission.Operator, "+ can change the nick of bots") }; }
} }
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("xnick", "-own") }; } get { return new[] { new CommandAlias("xnick", "-own") }; }
@ -34,11 +35,6 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) { UseBotOrPlayer(p, message, "nick"); } public override void Use(Player p, string message) { UseBotOrPlayer(p, message, "nick"); }
protected override void SetBotData(Player p, PlayerBot bot, string[] args) { protected override void SetBotData(Player p, PlayerBot bot, string[] args) {
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
Player.Message(p, "Hence, you cannot change that bot's nickname.");
return;
}
string newName = args.Length > 2 ? args[2] : ""; string newName = args.Length > 2 ? args[2] : "";
if (newName == "") { if (newName == "") {
bot.DisplayName = bot.name; bot.DisplayName = bot.name;

View File

@ -32,12 +32,26 @@ namespace MCGalaxy.Commands {
else who = PlayerInfo.FindMatches(p, args[0]); else who = PlayerInfo.FindMatches(p, args[0]);
if (bot == null && who == null) return; if (bot == null && who == null) return;
if (p != null && who != null && who.Rank > p.Rank) { if (isBot) {
MessageTooHighRank(p, "change the " + type + " of", true); return; if (!CheckExtraPerm(p, 2)) {
MessageNeedExtra(p, "change the " + type + " of bots.", 2); return;
}
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
Player.Message(p, "Hence, you cannot change the " + type + " of that bot.");
return;
}
SetBotData(p, bot, args);
} else {
if (p != who && !CheckExtraPerm(p, 1)) {
MessageNeedExtra(p, "change the " + type + " of others.", 1); return;
}
if (p != null && who.Rank > p.Rank) {
MessageTooHighRank(p, "change the " + type + " of", true); return;
}
SetPlayerData(p, who, args);
} }
if ((isBot || p != who) && !CheckExtraPerm(p)) { MessageNeedExtra(p, "change the " + type + " of others."); return; }
if (isBot) SetBotData(p, bot, args);
else SetPlayerData(p, who, args);
} }
protected void UsePlayer(Player p, string message, string type) { protected void UsePlayer(Player p, string message, string type) {