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 LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
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 {
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) {
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);
bot.model = model;
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 LevelPermission defaultRank { get { return LevelPermission.Operator; } }
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) {
@ -34,14 +35,9 @@ namespace MCGalaxy.Commands.CPE {
message = message.TrimEnd();
}
UseBotOrPlayer(p, message, "skin");
}
}
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);
if (skin == null) return;
bot.SkinName = skin;

View File

@ -25,7 +25,8 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Chat; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
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 {
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"); }
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";
if (color == "") { Player.Message(p, "There is no color \"" + args[2] + "\"."); return; }
Chat.MessageLevel(bot.level, "Bot " + bot.ColoredName + "'s %Scolor was set to "

View File

@ -26,19 +26,15 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Chat; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
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 {
get { return new[] { new CommandAlias("xnick", "-own") }; }
}
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) {
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] : "";
if (newName == "") {
bot.DisplayName = bot.name;

View File

@ -16,28 +16,42 @@
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands {
public abstract class EntityPropertyCmd : Command {
namespace MCGalaxy.Commands {
public abstract class EntityPropertyCmd : Command {
public override bool museumUsable { get { return true; } }
protected void UseBotOrPlayer(Player p, string message, string type) {
if (message == "") { Help(p); return; }
bool isBot = message.CaselessStarts("bot ");
bool isBot = message.CaselessStarts("bot ");
string[] args = message.SplitSpaces(isBot ? 3 : 2);
if (!CheckOwn(p, args, "player or bot name")) return;
Player who = null;
PlayerBot bot = null;
PlayerBot bot = null;
if (isBot) bot = PlayerBot.FindMatchesPreferLevel(p, args[1]);
else who = PlayerInfo.FindMatches(p, args[0]);
if (bot == null && who == null) return;
if (p != null && who != null && who.Rank > p.Rank) {
MessageTooHighRank(p, "change the " + type + " of", true); return;
if (isBot) {
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) {