mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 22:30:52 -04:00
Core: Prevent modifying bots on worlds you don't have perbuild access to.
This commit is contained in:
parent
04b8e79664
commit
0ea046961a
@ -28,6 +28,11 @@ namespace MCGalaxy.Commands {
|
|||||||
if (message == "") { Help(p); return; }
|
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;
|
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);
|
PlayerBot bot = new PlayerBot(message, p.level, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0);
|
||||||
PlayerBot.Add(bot);
|
PlayerBot.Add(bot);
|
||||||
|
@ -28,16 +28,22 @@ namespace MCGalaxy.Commands {
|
|||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (message == "") { Help(p); return; }
|
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")) {
|
if (message.CaselessEq("all")) {
|
||||||
PlayerBot.RemoveAllFromLevel(p.level); return;
|
PlayerBot.RemoveAllFromLevel(p.level); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerBot who = PlayerBot.FindMatchesPreferLevel(p, message);
|
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, message);
|
||||||
if (who == null) return;
|
if (bot == null) return;
|
||||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
if (!p.level.name.CaselessEq(bot.level.name)) {
|
||||||
Player.Message(p, who.ColoredName + " %Sis in a different level."); return;
|
Player.Message(p, bot.ColoredName + " %Sis in a different level."); return;
|
||||||
}
|
}
|
||||||
PlayerBot.Remove(who);
|
PlayerBot.Remove(bot);
|
||||||
Player.Message(p, "Removed bot.");
|
Player.Message(p, "Removed bot.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,11 @@ namespace MCGalaxy.Commands {
|
|||||||
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]);
|
PlayerBot bot = PlayerBot.FindMatchesPreferLevel(p, args[0]);
|
||||||
if (bot == null) return;
|
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) {
|
if (args.Length == 1) {
|
||||||
bot.Instructions.Clear();
|
bot.Instructions.Clear();
|
||||||
bot.kill = false;
|
bot.kill = false;
|
||||||
|
@ -30,13 +30,18 @@ namespace MCGalaxy.Commands {
|
|||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
if (p == null) { MessageInGameOnly(p); return; }
|
if (p == null) { MessageInGameOnly(p); return; }
|
||||||
|
|
||||||
PlayerBot who = PlayerBot.FindMatchesPreferLevel(p, message);
|
if (!p.level.BuildAccess.CheckDetailed(p)) {
|
||||||
if (who == null) return;
|
Player.Message(p, "Hence, you cannot summon bots on this map.");
|
||||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
return;
|
||||||
Player.Message(p, who.name + " is in a different level."); 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) {
|
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"); }
|
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user