mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 14:17:29 -04:00
Core: Prevent modifying bots on worlds you don't have perbuild access to.
This commit is contained in:
parent
04b8e79664
commit
0ea046961a
@ -26,7 +26,12 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
if (!p.level.BuildAccess.CheckDetailed(p)) {
|
||||
Player.Message(p, "Hence, you cannot add bots to this map.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Formatter.ValidName(p, message, "bot")) return;
|
||||
PlayerBot bot = new PlayerBot(message, p.level, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0);
|
||||
|
@ -27,17 +27,23 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
if (!p.level.BuildAccess.CheckDetailed(p)) {
|
||||
Player.Message(p, "Hence, you cannot change remove bots from this map.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.CaselessEq("all")) {
|
||||
PlayerBot.RemoveAllFromLevel(p.level); return;
|
||||
}
|
||||
|
||||
PlayerBot who = PlayerBot.FindMatchesPreferLevel(p, message);
|
||||
if (who == null) return;
|
||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
||||
Player.Message(p, who.ColoredName + " %Sis in a different level."); return;
|
||||
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, message);
|
||||
if (bot == null) return;
|
||||
if (!p.level.name.CaselessEq(bot.level.name)) {
|
||||
Player.Message(p, bot.ColoredName + " %Sis in a different level."); return;
|
||||
}
|
||||
PlayerBot.Remove(who);
|
||||
PlayerBot.Remove(bot);
|
||||
Player.Message(p, "Removed bot.");
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,11 @@ namespace MCGalaxy.Commands {
|
||||
string[] args = message.Split(' ');
|
||||
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]);
|
||||
if (bot == null) return;
|
||||
|
||||
if (p != null && !bot.level.BuildAccess.CheckDetailed(p)) {
|
||||
Player.Message(p, "Hence, you cannot change the AI of bots on this map.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length == 1) {
|
||||
bot.Instructions.Clear();
|
||||
|
@ -29,14 +29,19 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
PlayerBot who = PlayerBot.FindMatchesPreferLevel(p, message);
|
||||
if (who == null) return;
|
||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
||||
Player.Message(p, who.name + " is in a different level."); return;
|
||||
|
||||
if (!p.level.BuildAccess.CheckDetailed(p)) {
|
||||
Player.Message(p, "Hence, you cannot summon bots on this map.");
|
||||
return;
|
||||
}
|
||||
who.SetPos(p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
|
||||
BotsFile.UpdateBot(who);
|
||||
|
||||
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, message);
|
||||
if (bot == null) return;
|
||||
if (!p.level.name.CaselessEq(bot.level.name)) {
|
||||
Player.Message(p, bot.name + " is in a different level."); return;
|
||||
}
|
||||
bot.SetPos(p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
|
||||
BotsFile.UpdateBot(bot);
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -34,6 +34,11 @@ namespace MCGalaxy.Commands {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user