Now /os map pervisit/perbuild act is if you have nobody permissions

This commit is contained in:
UnknownShadow200 2018-07-11 19:30:58 +10:00
parent 7a43580bfd
commit 0c6dca20c5
47 changed files with 172 additions and 208 deletions

View File

@ -33,7 +33,9 @@ namespace MCGalaxy.Commands.Bots {
if (message.Length == 0) { Help(p); return; } if (message.Length == 0) { Help(p); return; }
string[] args = message.SplitSpaces(3); string[] args = message.SplitSpaces(3);
if (args.Length < 2) { Help(p); return; } if (args.Length < 2) { Help(p); return; }
if (!Formatter.ValidName(p, args[1], "bot")) return; if (!Formatter.ValidName(p, args[1], "bot")) return;
if (!LevelInfo.ValidateAction(p, data, p.level, "modify bots in this level")) return;
string bot = args[1], value = args.Length > 2 ? args[2] : null; string bot = args[1], value = args.Length > 2 ? args[2] : null;
if (args[0].CaselessEq("add")) { if (args[0].CaselessEq("add")) {
@ -54,7 +56,6 @@ namespace MCGalaxy.Commands.Bots {
} }
void AddBot(Player p, string botName) { void AddBot(Player p, string botName) {
if (!LevelInfo.ValidateAction(p, p.level, "add bots to this level")) return;
PlayerBot bot = new PlayerBot(botName, p.level); PlayerBot bot = new PlayerBot(botName, p.level);
TryAddBot(p, bot); TryAddBot(p, bot);
} }
@ -84,8 +85,6 @@ namespace MCGalaxy.Commands.Bots {
} }
void RemoveBot(Player p, string botName) { void RemoveBot(Player p, string botName) {
if (!LevelInfo.ValidateAction(p, p.level, "remove bots from this level")) return;
if (botName.CaselessEq("all")) { if (botName.CaselessEq("all")) {
PlayerBot.RemoveLoadedBots(p.level, false); PlayerBot.RemoveLoadedBots(p.level, false);
BotsFile.Save(p.level); BotsFile.Save(p.level);
@ -101,8 +100,7 @@ namespace MCGalaxy.Commands.Bots {
void SetBotText(Player p, string botName, string text) { void SetBotText(Player p, string botName, string text) {
PlayerBot bot = Matcher.FindBots(p, botName); PlayerBot bot = Matcher.FindBots(p, botName);
if (bot == null) return; if (bot == null) return;
if (!LevelInfo.ValidateAction(p, p.level, "set bot text of that bot")) return;
if (text == null) { if (text == null) {
p.Message("Removed text shown when bot {0} %Sclicked on", bot.ColoredName); p.Message("Removed text shown when bot {0} %Sclicked on", bot.ColoredName);
bot.ClickedOnText = null; bot.ClickedOnText = null;
@ -117,8 +115,7 @@ namespace MCGalaxy.Commands.Bots {
void SetDeathMessage(Player p, string botName, string text) { void SetDeathMessage(Player p, string botName, string text) {
PlayerBot bot = Matcher.FindBots(p, botName); PlayerBot bot = Matcher.FindBots(p, botName);
if (bot == null) return; if (bot == null) return;
if (!LevelInfo.ValidateAction(p, p.level, "set kill message of that bot")) return;
if (text == null) { if (text == null) {
p.Message("Reset shown when bot {0} %Skills someone", bot.ColoredName); p.Message("Reset shown when bot {0} %Skills someone", bot.ColoredName);
bot.DeathMessage = null; bot.DeathMessage = null;
@ -131,7 +128,6 @@ namespace MCGalaxy.Commands.Bots {
} }
void RenameBot(Player p, string botName, string newName) { void RenameBot(Player p, string botName, string newName) {
if (!LevelInfo.ValidateAction(p, p.level, "rename bots on this level")) return;
if (newName == null) { p.Message("New name of bot required."); return; } if (newName == null) { p.Message("New name of bot required."); return; }
if (!Formatter.ValidName(p, newName, "bot")) return; if (!Formatter.ValidName(p, newName, "bot")) return;
@ -153,7 +149,6 @@ namespace MCGalaxy.Commands.Bots {
} }
void CopyBot(Player p, string botName, string newName) { void CopyBot(Player p, string botName, string newName) {
if (!LevelInfo.ValidateAction(p, p.level, "copy bots on this level")) return;
if (newName == null) { p.Message("Name of new bot required."); return; } if (newName == null) { p.Message("Name of new bot required."); return; }
if (!Formatter.ValidName(p, newName, "bot")) return; if (!Formatter.ValidName(p, newName, "bot")) return;

View File

@ -35,7 +35,7 @@ namespace MCGalaxy.Commands.Bots {
string[] args = message.SplitSpaces(); string[] args = message.SplitSpaces();
PlayerBot bot = Matcher.FindBots(p, args[0]); PlayerBot bot = Matcher.FindBots(p, args[0]);
if (bot == null) return; if (bot == null) return;
if (!LevelInfo.ValidateAction(p, p.level, "change AI of bots in this level")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "change AI of bots in this level")) return;
if (args.Length == 1) { if (args.Length == 1) {
bot.Instructions.Clear(); bot.Instructions.Clear();

View File

@ -27,7 +27,7 @@ namespace MCGalaxy.Commands.Bots {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (message.Length == 0) { Help(p); return; } if (message.Length == 0) { Help(p); return; }
if (!LevelInfo.ValidateAction(p, p.level, "summon that bot")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "summon that bot")) return;
PlayerBot bot = Matcher.FindBots(p, message); PlayerBot bot = Matcher.FindBots(p, message);
if (bot == null) return; if (bot == null) return;

View File

@ -34,7 +34,7 @@ namespace MCGalaxy.Commands.CPE {
message = "-own " + message; message = "-own " + message;
message = message.TrimEnd(); message = message.TrimEnd();
} }
UseBotOrPlayer(p, message, "rotation"); UseBotOrPlayer(p, data, message, "rotation");
} }
protected override void SetBotData(Player p, PlayerBot bot, string args) { protected override void SetBotData(Player p, PlayerBot bot, string args) {

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.CPE {
} }
message = message.ToLower(); message = message.ToLower();
if (!LevelInfo.ValidateAction(p, p.level, "set env settings of this level")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "set env settings of this level")) return;
string[] args = message.SplitSpaces(); string[] args = message.SplitSpaces();
string opt = args[0]; string opt = args[0];

View File

@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.CPE {
message = "-own " + message; message = "-own " + message;
message = message.TrimEnd(); message = message.TrimEnd();
} }
UseBotOrPlayer(p, message, "model"); UseBotOrPlayer(p, data, message, "model");
} }
protected override void SetBotData(Player p, PlayerBot bot, string model) { protected override void SetBotData(Player p, PlayerBot bot, string model) {

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.CPE {
message = "-own " + message; message = "-own " + message;
message = message.TrimEnd(); message = message.TrimEnd();
} }
UseBotOrPlayer(p, message, "skin"); UseBotOrPlayer(p, data, message, "skin");
} }
protected override void SetBotData(Player p, PlayerBot bot, string skin) { protected override void SetBotData(Player p, PlayerBot bot, string skin) {

View File

@ -73,7 +73,7 @@ namespace MCGalaxy.Commands.CPE {
} }
UpdateGlobal(p); UpdateGlobal(p);
} else if (scope == "level" || scope == "levelzip") { } else if (scope == "level" || scope == "levelzip") {
if (!LevelInfo.ValidateAction(p, p.level, "set texture of this level")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "set texture of this level")) return;
p.level.Config.Terrain = ""; p.level.Config.Terrain = "";
p.level.Config.TexturePack = ""; p.level.Config.TexturePack = "";

View File

@ -30,11 +30,11 @@ namespace MCGalaxy.Commands.Chatting {
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") }; }
} }
public override void Use(Player p, string message, CommandData data) { UseBotOrPlayer(p, message, "color"); } public override void Use(Player p, string message, CommandData data) {
UseBotOrPlayer(p, data, message, "color");
}
protected override void SetBotData(Player p, PlayerBot bot, string colName) { protected override void SetBotData(Player p, PlayerBot bot, string colName) {
if (!LevelInfo.ValidateAction(p, p.level, "change color of that bot")) return;
string color = colName.Length == 0 ? "&1" : Matcher.FindColor(p, colName); string color = colName.Length == 0 ? "&1" : Matcher.FindColor(p, colName);
if (color == null) return; if (color == null) return;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Chatting {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (!MessageCmd.CanSpeak(p, name)) return; if (!MessageCmd.CanSpeak(p, name)) return;
UsePlayer(p, message, "login message"); UsePlayer(p, data, message, "login message");
} }
protected override void SetPlayerData(Player p, Player who, string msg) { protected override void SetPlayerData(Player p, Player who, string msg) {

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Chatting {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (!MessageCmd.CanSpeak(p, name)) return; if (!MessageCmd.CanSpeak(p, name)) return;
UsePlayer(p, message, "logout message"); UsePlayer(p, data, message, "logout message");
} }
protected override void SetPlayerData(Player p, Player who, string msg) { protected override void SetPlayerData(Player p, Player who, string msg) {

View File

@ -36,7 +36,7 @@ namespace MCGalaxy.Commands.Chatting {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (!MessageCmd.CanSpeak(p, name)) return; if (!MessageCmd.CanSpeak(p, name)) return;
UseBotOrPlayer(p, message, "nick"); UseBotOrPlayer(p, data, message, "nick");
} }
protected override void SetBotData(Player p, PlayerBot bot, string nick) { protected override void SetBotData(Player p, PlayerBot bot, string nick) {

View File

@ -28,7 +28,9 @@ namespace MCGalaxy.Commands.Chatting {
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("TColour"), new CommandAlias("XTColor", "-own") }; } get { return new[] { new CommandAlias("TColour"), new CommandAlias("XTColor", "-own") }; }
} }
public override void Use(Player p, string message, CommandData data) { UsePlayer(p, message, "title color"); } public override void Use(Player p, string message, CommandData data) {
UsePlayer(p, data, message, "title color");
}
protected override void SetPlayerData(Player p, Player who, string colName) { protected override void SetPlayerData(Player p, Player who, string colName) {
string color = ""; string color = "";

View File

@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.Chatting {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (!MessageCmd.CanSpeak(p, name)) return; if (!MessageCmd.CanSpeak(p, name)) return;
UsePlayer(p, message, "title"); UsePlayer(p, data, message, "title");
} }
protected override void SetPlayerData(Player p, Player who, string title) { protected override void SetPlayerData(Player p, Player who, string title) {

View File

@ -19,7 +19,7 @@
namespace MCGalaxy.Commands { namespace MCGalaxy.Commands {
public abstract class EntityPropertyCmd : Command2 { public abstract class EntityPropertyCmd : Command2 {
protected void UseBotOrPlayer(Player p, string message, string type) { protected void UseBotOrPlayer(Player p, CommandData data, string message, string type) {
if (message.Length == 0) { Help(p); return; } if (message.Length == 0) { Help(p); return; }
bool isBot = message.CaselessStarts("bot "); bool isBot = message.CaselessStarts("bot ");
string[] args = message.SplitSpaces(isBot ? 3 : 2); string[] args = message.SplitSpaces(isBot ? 3 : 2);
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
if (isBot) { if (isBot) {
if (!CheckExtraPerm(p, 2)) return; if (!CheckExtraPerm(p, 2)) return;
if (!LevelInfo.ValidateAction(p, p.level, "change the " + type + " of that bot")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "change the " + type + " of that bot")) return;
SetBotData(p, bot, args.Length > 2 ? args[2] : ""); SetBotData(p, bot, args.Length > 2 ? args[2] : "");
} else { } else {
if (p != who && !CheckExtraPerm(p, 1)) return; if (p != who && !CheckExtraPerm(p, 1)) return;
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands {
} }
} }
protected void UsePlayer(Player p, string message, string type) { protected void UsePlayer(Player p, CommandData data, string message, string type) {
if (message.Length == 0) { Help(p); return; } if (message.Length == 0) { Help(p); return; }
string[] args = message.SplitSpaces(2); string[] args = message.SplitSpaces(2);
if (!CheckOwn(p, args, "player name")) return; if (!CheckOwn(p, args, "player name")) return;

View File

@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Maintenance {
lvl = Matcher.FindLevels(p, args[1]); lvl = Matcher.FindLevels(p, args[1]);
if (lvl == null) return; if (lvl == null) return;
} }
if (!LevelInfo.ValidateAction(p, lvl, "change BlockDB state of this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "change BlockDB state of this level")) return;
if (args[0].CaselessEq("clear")) { if (args[0].CaselessEq("clear")) {
p.Message("Clearing &cALL %Sblock changes for {0}%S...", lvl.ColoredName); p.Message("Clearing &cALL %Sblock changes for {0}%S...", lvl.ColoredName);

View File

@ -72,10 +72,10 @@ namespace MCGalaxy.Commands.Moderation {
Group grp = Matcher.FindRanks(p, parts[1]); Group grp = Matcher.FindRanks(p, parts[1]);
if (grp == null) return; if (grp == null) return;
if (ServerConfig.IRCControllerRank > p.Rank) { if (ServerConfig.IRCControllerRank > data.Rank) {
p.Message("Cannot change the IRC controllers rank, as it is currently a rank higher than yours."); return; p.Message("Cannot change the IRC controllers rank, as it is currently a rank higher than yours."); return;
} }
if (grp.Permission > p.Rank) { if (grp.Permission > data.Rank) {
p.Message("Cannot set the IRC controllers rank to a rank higher than yours."); return; p.Message("Cannot set the IRC controllers rank to a rank higher than yours."); return;
} }

View File

@ -41,7 +41,7 @@ namespace MCGalaxy.Commands.Moderation {
if (IsCreateCommand(opt)) { if (IsCreateCommand(opt)) {
if (args.Length == 1) { Help(p); return; } if (args.Length == 1) { Help(p); return; }
CreateZone(p, args, 1); CreateZone(p, args, data, 1);
} else if (IsDeleteCommand(opt)) { } else if (IsDeleteCommand(opt)) {
if (args.Length == 1) { Help(p); return; } if (args.Length == 1) { Help(p); return; }
DeleteZone(p, args); DeleteZone(p, args);
@ -53,25 +53,25 @@ namespace MCGalaxy.Commands.Moderation {
if (!zone.Access.CheckDetailed(p)) { if (!zone.Access.CheckDetailed(p)) {
p.Message("Hence, you cannot edit this zone."); return; p.Message("Hence, you cannot edit this zone."); return;
} else if (opt.CaselessEq("edit")) { } else if (opt.CaselessEq("edit")) {
EditZone(p, args, zone); EditZone(p, args, data, zone);
} else { } else {
SetZoneProp(p, args, zone); SetZoneProp(p, args, zone);
} }
} else { } else {
CreateZone(p, args, 0); CreateZone(p, args, data, 0);
} }
} }
void CreateZone(Player p, string[] args, int offset) { void CreateZone(Player p, string[] args, CommandData data, int offset) {
if (p.level.FindZoneExact(args[offset]) != null) { if (p.level.FindZoneExact(args[offset]) != null) {
p.Message("A zone with that name already exists. Use %T/zedit %Sto change it."); p.Message("A zone with that name already exists. Use %T/zedit %Sto change it.");
return; return;
} }
if (!LevelInfo.ValidateAction(p, args[0], "create zones in this level")) return; if (!LevelInfo.ValidateAction(p, data, args[0], "create zones in this level")) return;
Zone z = new Zone(); Zone z = new Zone();
z.Config.Name = args[offset]; z.Config.Name = args[offset];
if (!PermissionCmd.Do(p, args, offset + 1, false, z.Access, p.level)) return; if (!PermissionCmd.Do(p, args, offset + 1, false, z.Access, data, p.level)) return;
p.Message("Creating zone " + z.ColoredName); p.Message("Creating zone " + z.ColoredName);
p.Message("Place or break two blocks to determine the edges."); p.Message("Place or break two blocks to determine the edges.");
@ -106,8 +106,8 @@ namespace MCGalaxy.Commands.Moderation {
lvl.Save(true); lvl.Save(true);
} }
void EditZone(Player p, string[] args, Zone zone) { void EditZone(Player p, string[] args, CommandData data, Zone zone) {
PermissionCmd.Do(p, args, 2, false, zone.Access, p.level); PermissionCmd.Do(p, args, 2, false, zone.Access, data, p.level);
} }
void SetZoneProp(Player p, string[] args, Zone zone) { void SetZoneProp(Player p, string[] args, Zone zone) {

View File

@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.World {
string[] args = message.SplitSpaces(4); string[] args = message.SplitSpaces(4);
if (args.Length < 3) { Help(p); return; } if (args.Length < 3) { Help(p); return; }
BlockProps[] scope = GetScope(p, args[0]); BlockProps[] scope = GetScope(p, data, args[0]);
if (scope == null) return; if (scope == null) return;
Player pScope = scope == Block.Props ? null : p; Player pScope = scope == Block.Props ? null : p;
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.World {
SetProperty(p, scope, block, prop, args); SetProperty(p, scope, block, prop, args);
} }
static BlockProps[] GetScope(Player p, string scope) { static BlockProps[] GetScope(Player p, CommandData data, string scope) {
if (scope.CaselessEq("core") || scope.CaselessEq("global")) return Block.Props; if (scope.CaselessEq("core") || scope.CaselessEq("global")) return Block.Props;
if (scope.CaselessEq("level")) { if (scope.CaselessEq("level")) {
@ -52,7 +52,7 @@ namespace MCGalaxy.Commands.World {
p.Message("Cannot use level scope from {0}.", p.SuperName); return null; p.Message("Cannot use level scope from {0}.", p.SuperName); return null;
} }
if (!LevelInfo.ValidateAction(p, p.level, "change block properties in this level")) return null; if (!LevelInfo.ValidateAction(p, data, p.level, "change block properties in this level")) return null;
return p.level.Props; return p.level.Props;
} }

View File

@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.World {
string src = args[0]; string src = args[0];
src = Matcher.FindMaps(p, src); src = Matcher.FindMaps(p, src);
if (src == null) return; if (src == null) return;
if (!LevelInfo.ValidateAction(p, src, "copy this level")) return; if (!LevelInfo.ValidateAction(p, data, src, "copy this level")) return;
string dst = args[1]; string dst = args[1];
if (!Formatter.ValidName(p, dst, "level")) return; if (!Formatter.ValidName(p, dst, "level")) return;

View File

@ -36,7 +36,7 @@ namespace MCGalaxy.Commands.World {
if (map == null) return; if (map == null) return;
if (map.CaselessEq(ServerConfig.MainLevel)) { p.Message("Cannot delete the main level."); return; } if (map.CaselessEq(ServerConfig.MainLevel)) { p.Message("Cannot delete the main level."); return; }
if (!LevelInfo.ValidateAction(p, map, "delete this level")) return; if (!LevelInfo.ValidateAction(p, data, map, "delete this level")) return;
p.Message("Created backup."); p.Message("Created backup.");
if (LevelActions.Delete(map)) return; if (LevelActions.Delete(map)) return;

View File

@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.World {
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
int totalFixed = 0; int totalFixed = 0;
Level lvl = p.level; Level lvl = p.level;
if (!LevelInfo.ValidateAction(p, lvl, "use %T/fixgrass %Son this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "use %T/fixgrass %Son this level")) return;
if (message.Length == 0) { if (message.Length == 0) {
Fix(p, lvl, ref totalFixed, true, true); Fix(p, lvl, ref totalFixed, true, true);

View File

@ -39,11 +39,11 @@ namespace MCGalaxy.Commands.World {
} else { } else {
if (!CheckExtraPerm(p, 1)) return; if (!CheckExtraPerm(p, 1)) return;
if (!Formatter.ValidName(p, message, "level")) return; if (!Formatter.ValidName(p, message, "level")) return;
if (!LevelInfo.ValidateAction(p, Server.mainLevel, "set main to another level")) return; if (!LevelInfo.ValidateAction(p, data, Server.mainLevel, "set main to another level")) return;
string map = Matcher.FindMaps(p, message); string map = Matcher.FindMaps(p, message);
if (map == null) return; if (map == null) return;
if (!LevelInfo.ValidateAction(p, map, "set main to this level")) return; if (!LevelInfo.ValidateAction(p, data, map, "set main to this level")) return;
Server.SetMainLevel(map); Server.SetMainLevel(map);
SrvProperties.Save(); SrvProperties.Save();

View File

@ -60,7 +60,7 @@ namespace MCGalaxy.Commands.World {
if (!CheckExtraPerm(p, 1)) return; if (!CheckExtraPerm(p, 1)) return;
if (optName.CaselessEq(LevelOptions.RealmOwner) && !CheckExtraPerm(p, 2)) return; if (optName.CaselessEq(LevelOptions.RealmOwner) && !CheckExtraPerm(p, 2)) return;
if (!LevelInfo.ValidateAction(p, lvl, "change map settings of this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "change map settings of this level")) return;
LevelOption opt = LevelOptions.Find(optName); LevelOption opt = LevelOptions.Find(optName);
if (opt == null) { if (opt == null) {

View File

@ -113,14 +113,15 @@ namespace MCGalaxy.Commands.World {
string[] args = value.SplitSpaces(); string[] args = value.SplitSpaces();
if (args.Length < 4) { Command.Find("ResizeLvl").Help(p); return; } if (args.Length < 4) { Command.Find("ResizeLvl").Help(p); return; }
if (CmdResizeLvl.DoResize(p, args)) return; CommandData data = default(CommandData); data.Rank = p.Rank;
if (CmdResizeLvl.DoResize(p, args, data)) return;
p.Message("Type %T/os map resize {0} {1} {2} confirm %Sif you're sure.", p.Message("Type %T/os map resize {0} {1} {2} confirm %Sif you're sure.",
args[1], args[2], args[3]); args[1], args[2], args[3]);
} else if (cmd == "PERVISIT") { } else if (cmd == "PERVISIT") {
// Older realm maps didn't put you on visit whitelist, so make sure we put the owner here // Older realm maps didn't put you on visit whitelist, so make sure we put the owner here
AccessController access = p.level.VisitAccess; AccessController access = p.level.VisitAccess;
if (!access.Whitelisted.CaselessContains(p.name)) { if (!access.Whitelisted.CaselessContains(p.name)) {
access.Whitelist(Player.Console, p.level, p.name); access.Whitelist(Player.Console, LevelPermission.Nobody, p.level, p.name);
} }
UseCommand(p, "PerVisit", value); UseCommand(p, "PerVisit", value);
} else if (cmd == "PERBUILD") { } else if (cmd == "PERBUILD") {
@ -179,13 +180,14 @@ namespace MCGalaxy.Commands.World {
internal static bool SetPerms(Player p, Level lvl) { internal static bool SetPerms(Player p, Level lvl) {
lvl.Config.RealmOwner = p.name; lvl.Config.RealmOwner = p.name;
lvl.BuildAccess.Whitelist(Player.Console, lvl, p.name); const LevelPermission rank = LevelPermission.Nobody;
lvl.VisitAccess.Whitelist(Player.Console, lvl, p.name); lvl.BuildAccess.Whitelist(Player.Console, rank, lvl, p.name);
lvl.VisitAccess.Whitelist(Player.Console, rank, lvl, p.name);
Group grp = Group.Find(ServerConfig.OSPerbuildDefault); Group grp = Group.Find(ServerConfig.OSPerbuildDefault);
if (grp == null) return false; if (grp == null) return false;
lvl.BuildAccess.SetMin(Player.Console, lvl, grp); lvl.BuildAccess.SetMin(Player.Console, rank, lvl, grp);
return true; return true;
} }
@ -219,80 +221,24 @@ namespace MCGalaxy.Commands.World {
if (cmd == "LIST") { if (cmd == "LIST") {
UseCommand(p, "ZoneList", ""); UseCommand(p, "ZoneList", "");
} else if (cmd == "ADD") { } else if (cmd == "ADD") {
if (name.Length == 0) { p.Message("You need to provide a player name."); return; } UseCommand(p, "PerBuild", "+" + name);
AddBuildPlayer(p, name);
} else if (IsDeleteCommand(cmd)) { } else if (IsDeleteCommand(cmd)) {
if (name.Length == 0) { p.Message("You need to provide a player name."); return; } UseCommand(p, "PerBuild", "-" + name);
DeleteBuildPlayer(p, name);
} else if (cmd == "BLOCK") { } else if (cmd == "BLOCK") {
if (name.Length == 0) { p.Message("You need to provide a player name."); return; } UseCommand(p, "PerVisit", "-" + name);
name = PlayerInfo.FindMatchesPreferOnline(p, name);
if (name == null) return;
if (name.CaselessEq(p.name)) { p.Message("You can't blacklist yourself"); return; }
RemoveVisitPlayer(p, name);
} else if (cmd == "UNBLOCK") { } else if (cmd == "UNBLOCK") {
if (name.Length == 0) { p.Message("You need to provide a player name."); return; } UseCommand(p, "PerVisit", "+" + name);
if (!Formatter.ValidName(p, name, "player")) return;
AddVisitPlayer(p, name);
} else if (cmd == "BLACKLIST") { } else if (cmd == "BLACKLIST") {
List<string> blacklist = p.level.VisitAccess.Blacklisted; List<string> blacklist = p.level.VisitAccess.Blacklisted;
if (blacklist.Count > 0) { if (blacklist.Count > 0) {
p.Message("Blacklisted players: " + blacklist.Join()); p.Message("Blacklisted players: " + blacklist.Join());
} else { } else {
p.Message("There are no blacklisted players on this map."); p.Message("No players are blacklisted from visiting this map.");
} }
} else { } else {
p.MessageLines(zoneHelp); p.MessageLines(zoneHelp);
} }
} }
static void AddBuildPlayer(Player p, string rawArgs) {
string[] args = rawArgs.SplitSpaces();
string reason = args.Length > 1 ? args[1] : "";
string name = ModActionCmd.FindName(p, "zone", "os zone add", "", args[0], ref reason);
if (name == null) return;
p.Message("Added zone for &b" + name);
LevelAccessController access = p.level.BuildAccess;
if (access.Blacklisted.CaselessRemove(name)) {
access.OnListChanged(p, p.level, name, true, true);
}
if (!access.Whitelisted.CaselessContains(name)) {
access.Whitelisted.Add(name);
access.OnListChanged(p, p.level, name, true, false);
}
}
static void DeleteBuildPlayer(Player p, string name) {
if (!Formatter.ValidName(p, name, "player")) return;
LevelAccessController access = p.level.BuildAccess;
if (access.Whitelisted.CaselessRemove(name)) {
access.OnListChanged(p, p.level, name, false, true);
} else {
p.Message(name + " was not whitelisted.");
}
}
static void AddVisitPlayer(Player p, string name) {
List<string> blacklist = p.level.VisitAccess.Blacklisted;
if (!blacklist.CaselessContains(name)) {
p.Message(name + " is not blacklisted."); return;
}
blacklist.CaselessRemove(name);
p.level.VisitAccess.OnListChanged(p, p.level, name, true, true);
}
static void RemoveVisitPlayer(Player p, string name) {
List<string> blacklist = p.level.VisitAccess.Blacklisted;
if (blacklist.CaselessContains(name)) {
p.Message(name + " is already blacklisted."); return;
}
blacklist.Add(name);
p.level.VisitAccess.OnListChanged(p, p.level, name, false, false);
}
static void HandleZones(Player p, string cmd, string args) { static void HandleZones(Player p, string cmd, string args) {
if (args.Length == 0) { if (args.Length == 0) {
p.Message("Arguments required. See %T/Help zone"); p.Message("Arguments required. See %T/Help zone");

View File

@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.World {
} }
} }
if (!LevelInfo.ValidateAction(p, lvl, "pause physics on this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "pause physics on this level")) return;
bool enabled = lvl.PhysicsPaused; bool enabled = lvl.PhysicsPaused;
lvl.PhysicsPaused = !lvl.PhysicsPaused; lvl.PhysicsPaused = !lvl.PhysicsPaused;

View File

@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.World {
if (lvl == null) return; if (lvl == null) return;
} }
if (!LevelInfo.ValidateAction(p, lvl, "set physics of this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "set physics of this level")) return;
SetPhysics(lvl, state); SetPhysics(lvl, state);
} }

View File

@ -39,7 +39,7 @@ namespace MCGalaxy.Commands.World {
if (LevelInfo.MapExists(newName)) { p.Message("Level already exists."); return; } if (LevelInfo.MapExists(newName)) { p.Message("Level already exists."); return; }
if (lvl == Server.mainLevel) { p.Message("Cannot rename the main level."); return; } if (lvl == Server.mainLevel) { p.Message("Cannot rename the main level."); return; }
if (!LevelInfo.ValidateAction(p, lvl, "rename this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "rename this level")) return;
List<Player> players = lvl.getPlayers(); List<Player> players = lvl.getPlayers();
lvl.Unload(); lvl.Unload();

View File

@ -33,15 +33,15 @@ namespace MCGalaxy.Commands.World {
string[] args = message.SplitSpaces(); string[] args = message.SplitSpaces();
if (args.Length < 4) { Help(p); return; } if (args.Length < 4) { Help(p); return; }
if (DoResize(p, args)) return; if (DoResize(p, args, data)) return;
p.Message("Type %T/ResizeLvl {0} {1} {2} {3} confirm %Sif you're sure.", p.Message("Type %T/ResizeLvl {0} {1} {2} {3} confirm %Sif you're sure.",
args[0], args[1], args[2], args[3]); args[0], args[1], args[2], args[3]);
} }
public static bool DoResize(Player p, string[] args) { public static bool DoResize(Player p, string[] args, CommandData data) {
Level lvl = Matcher.FindLevels(p, args[0]); Level lvl = Matcher.FindLevels(p, args[0]);
if (lvl == null) return true; if (lvl == null) return true;
if (!LevelInfo.ValidateAction(p, lvl, "resize this level")) return false; if (!LevelInfo.ValidateAction(p, data, lvl, "resize this level")) return false;
ushort x = 0, y = 0, z = 0; ushort x = 0, y = 0, z = 0;
if (!CmdNewLvl.CheckMapAxis(p, args[1], "Width", ref x)) return false; if (!CmdNewLvl.CheckMapAxis(p, args[1], "Width", ref x)) return false;

View File

@ -42,7 +42,7 @@ namespace MCGalaxy.Commands.World {
lvl = p.level; lvl = p.level;
} }
if (!LevelInfo.ValidateAction(p, lvl, "restore a backup of this level")) return; if (!LevelInfo.ValidateAction(p, data, lvl, "restore a backup of this level")) return;
if (File.Exists(LevelInfo.BackupFilePath(lvl.name, args[0]))) { if (File.Exists(LevelInfo.BackupFilePath(lvl.name, args[0]))) {
try { try {
DoRestore(lvl, args[0]); DoRestore(lvl, args[0]);

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Commands.World {
public override bool SuperUseable { get { return false; } } public override bool SuperUseable { get { return false; } }
public override void Use(Player p, string message, CommandData data) { public override void Use(Player p, string message, CommandData data) {
if (!LevelInfo.ValidateAction(p, p.level, "set spawn of this level")) return; if (!LevelInfo.ValidateAction(p, data, p.level, "set spawn of this level")) return;
if (message.Length == 0) { if (message.Length == 0) {
p.Message("Spawn location set to your current location."); p.Message("Spawn location set to your current location.");

View File

@ -24,25 +24,26 @@ namespace MCGalaxy.Commands.World {
public override bool museumUsable { get { return false; } } public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public static bool Do(Player p, string[] args, int offset, bool max, AccessController access, Level lvl) { public static bool Do(Player p, string[] args, int offset, bool max,
AccessController access, CommandData data, Level lvl) {
for (int i = offset; i < args.Length; i++) { for (int i = offset; i < args.Length; i++) {
string arg = args[i]; string arg = args[i];
if (arg[0] == '+' || arg[0] == '-') { if (arg[0] == '+' || arg[0] == '-') {
if (!SetList(p, access, arg, lvl)) return false; if (!SetList(p, arg, access, data, lvl)) return false;
} else if (max) { } else if (max) {
Group grp = Matcher.FindRanks(p, arg); Group grp = Matcher.FindRanks(p, arg);
if (grp == null) return false; if (grp == null) return false;
access.SetMax(p, lvl, grp); access.SetMax(p, data.Rank, lvl, grp);
} else { } else {
Group grp = Matcher.FindRanks(p, arg); Group grp = Matcher.FindRanks(p, arg);
if (grp == null) return false; if (grp == null) return false;
access.SetMin(p, lvl, grp); access.SetMin(p, data.Rank, lvl, grp);
} }
} }
return true; return true;
} }
protected void DoLevel(Player p, string message, bool visit) { protected void DoLevel(Player p, string message, CommandData data, bool visit) {
const string maxPrefix = "-max "; const string maxPrefix = "-max ";
bool max = message.CaselessStarts(maxPrefix); bool max = message.CaselessStarts(maxPrefix);
if (max) message = message.Substring(maxPrefix.Length); if (max) message = message.Substring(maxPrefix.Length);
@ -54,7 +55,7 @@ namespace MCGalaxy.Commands.World {
} }
string map = args.Length == 1 ? p.level.name : Matcher.FindMaps(p, args[0]); string map = args.Length == 1 ? p.level.name : Matcher.FindMaps(p, args[0]);
if (map == null) return; if (map == null) return;
Level lvl; Level lvl;
LevelConfig cfg = LevelInfo.GetConfig(map, out lvl); LevelConfig cfg = LevelInfo.GetConfig(map, out lvl);
int offset = args.Length == 1 ? 0 : 1; int offset = args.Length == 1 ? 0 : 1;
@ -65,10 +66,11 @@ namespace MCGalaxy.Commands.World {
} else { } else {
access = visit ? lvl.VisitAccess : lvl.BuildAccess; access = visit ? lvl.VisitAccess : lvl.BuildAccess;
} }
Do(p, args, offset, max, access, lvl); Do(p, args, offset, max, access, data, lvl);
} }
static bool SetList(Player p, AccessController access, string name, Level lvl) { static bool SetList(Player p, string name,
AccessController access, CommandData data, Level lvl) {
bool include = name[0] == '+'; bool include = name[0] == '+';
string mode = include ? "whitelist" : "blacklist"; string mode = include ? "whitelist" : "blacklist";
name = name.Substring(1); name = name.Substring(1);
@ -86,9 +88,9 @@ namespace MCGalaxy.Commands.World {
} }
if (include) { if (include) {
access.Whitelist(p, lvl, name); access.Whitelist(p, data.Rank, lvl, name);
} else { } else {
access.Blacklist(p, lvl, name); access.Blacklist(p, data.Rank, lvl, name);
} }
return true; return true;
} }
@ -115,7 +117,7 @@ namespace MCGalaxy.Commands.World {
get { return new[] { new CommandPerm(LevelPermission.Operator, "bypass max build rank restriction") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "bypass max build rank restriction") }; }
} }
public override void Use(Player p, string message, CommandData data) { DoLevel(p, message, false); } public override void Use(Player p, string message, CommandData data) { DoLevel(p, message, data, false); }
public override void Help(Player p) { ShowHelp(p, "build on", "build"); } public override void Help(Player p) { ShowHelp(p, "build on", "build"); }
} }
@ -129,7 +131,7 @@ namespace MCGalaxy.Commands.World {
get { return new[] { new CommandPerm(LevelPermission.Operator, "bypass max visit rank restriction") }; } get { return new[] { new CommandPerm(LevelPermission.Operator, "bypass max visit rank restriction") }; }
} }
public override void Use(Player p, string message, CommandData data) { DoLevel(p, message, true); } public override void Use(Player p, string message, CommandData data) { DoLevel(p, message, data, true); }
public override void Help(Player p) { ShowHelp(p, "visit", "visit"); } public override void Help(Player p) { ShowHelp(p, "visit", "visit"); }
} }
} }

View File

@ -48,7 +48,7 @@ namespace MCGalaxy.Commands.Misc {
if (pl.level == p.level && pl != p && p.Rank > pl.Rank) { if (pl.level == p.level && pl != p && p.Rank > pl.Rank) {
pl.AFKCooldown = DateTime.UtcNow.AddSeconds(2); pl.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
pl.SendPos(Entities.SelfID, p.Pos, p.Rot); pl.SendPos(Entities.SelfID, p.Pos, p.Rot);
pl.SendMessage("You were summoned by " + p.ColoredName + "%S."); pl.Message("You were summoned by " + p.ColoredName + "%S.");
} }
} }
Chat.MessageFromLevel(p, "λNICK %Ssummoned everyone"); Chat.MessageFromLevel(p, "λNICK %Ssummoned everyone");
@ -76,7 +76,7 @@ namespace MCGalaxy.Commands.Misc {
who.AFKCooldown = DateTime.UtcNow.AddSeconds(2); who.AFKCooldown = DateTime.UtcNow.AddSeconds(2);
who.SendPos(Entities.SelfID, p.Pos, p.Rot); who.SendPos(Entities.SelfID, p.Pos, p.Rot);
who.SendMessage("You were summoned by " + p.ColoredName + "%S."); who.Message("You were summoned by " + p.ColoredName + "%S.");
} }
static bool CheckVisitPerm(Player p, Player who, bool confirmed) { static bool CheckVisitPerm(Player p, Player who, bool confirmed) {

View File

@ -202,7 +202,7 @@ namespace MCGalaxy.Core {
LogAction(e, who, action + newRank.ColoredName); LogAction(e, who, action + newRank.ColoredName);
if (who != null && e.Announce) { if (who != null && e.Announce) {
who.SendMessage("You are now ranked " + newRank.ColoredName + "%S, type /Help for your new set of commands."); who.Message("You are now ranked " + newRank.ColoredName + "%S, type /Help for your new set of commands.");
} }
if (Server.tempRanks.Remove(e.Target)) { if (Server.tempRanks.Remove(e.Target)) {
ModerationTasks.TemprankCalcNextRun(); ModerationTasks.TemprankCalcNextRun();

View File

@ -36,7 +36,7 @@ namespace MCGalaxy.Drawing.Brushes {
internal static Brush ProcessReplace(BrushArgs args, bool not) { internal static Brush ProcessReplace(BrushArgs args, bool not) {
string[] parts = args.Message.SplitSpaces(); string[] parts = args.Message.SplitSpaces();
if (args.Message.Length == 0) { if (args.Message.Length == 0) {
args.Player.SendMessage("You need at least one block to replace."); return null; args.Player.Message("You need at least one block to replace."); return null;
} }
int count = parts.Length == 1 ? 1 : parts.Length - 1; int count = parts.Length == 1 ? 1 : parts.Length - 1;

View File

@ -102,7 +102,7 @@ namespace MCGalaxy.Drawing.Brushes {
public override Brush Construct(BrushArgs args) { public override Brush Construct(BrushArgs args) {
CopyState cState = args.Player.CurrentCopy; CopyState cState = args.Player.CurrentCopy;
if (cState == null) { if (cState == null) {
args.Player.SendMessage("You haven't copied anything yet."); args.Player.Message("You haven't copied anything yet.");
return null; return null;
} }

View File

@ -94,7 +94,7 @@ namespace MCGalaxy.Games {
foreach (Player pl in players) { foreach (Player pl in players) {
if (pl.level != Map) { if (pl.level != Map) {
pl.SendMessage("Sending you to the correct map."); pl.Message("Sending you to the correct map.");
PlayerActions.ChangeMap(pl, Map.name); PlayerActions.ChangeMap(pl, Map.name);
} }
@ -223,7 +223,7 @@ namespace MCGalaxy.Games {
UpdateAllStatus(); UpdateAllStatus();
if (winner != null) { if (winner != null) {
winner.SendMessage("Congratulations, you won this round of countdown!"); winner.Message("Congratulations, you won this round of countdown!");
PlayerActions.Respawn(winner); PlayerActions.Respawn(winner);
} else { } else {
Player[] players = Players.Items; Player[] players = Players.Items;

View File

@ -97,7 +97,7 @@ namespace MCGalaxy.Games {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
if (pl.level != game.Map || pl.Supports(CpeExt.MessageTypes)) continue; if (pl.level != game.Map || pl.Supports(CpeExt.MessageTypes)) continue;
pl.SendMessage("You have " + VoteTime + " seconds to vote for the next map"); pl.Message("You have " + VoteTime + " seconds to vote for the next map");
} }
Level map = game.Map; Level map = game.Map;

View File

@ -203,7 +203,7 @@ namespace MCGalaxy.Games {
int i = rnd.Next(0, transfers.Count); int i = rnd.Next(0, transfers.Count);
Player pl = transfers[i]; Player pl = transfers[i];
pl.SendMessage("Going to the next map - &a" + Map.MapName); pl.Message("Going to the next map - &a" + Map.MapName);
PlayerActions.ChangeMap(pl, Map); PlayerActions.ChangeMap(pl, Map);
transfers.RemoveAt(i); transfers.RemoveAt(i);
} }

View File

@ -125,7 +125,7 @@ namespace MCGalaxy.Games {
if (lastKiller == killer.name) { if (lastKiller == killer.name) {
infectCombo++; infectCombo++;
if (infectCombo >= 2) { if (infectCombo >= 2) {
killer.SendMessage("You gained " + (2 + infectCombo) + " " + ServerConfig.Currency); killer.Message("You gained " + (2 + infectCombo) + " " + ServerConfig.Currency);
killer.SetMoney(killer.money + (2 + infectCombo)); killer.SetMoney(killer.money + (2 + infectCombo));
Map.Message("&c" + killer.DisplayName + " %Sis on a rampage! " + (infectCombo + 1) + " infections in a row!"); Map.Message("&c" + killer.DisplayName + " %Sis on a rampage! " + (infectCombo + 1) + " infections in a row!");
} }
@ -293,9 +293,9 @@ namespace MCGalaxy.Games {
int reward = GetMoneyReward(pl, data, alive, rand); int reward = GetMoneyReward(pl, data, alive, rand);
if (reward == -1) { if (reward == -1) {
pl.SendMessage("You may not hide inside a block! No " + ServerConfig.Currency + " for you."); reward = 0; pl.Message("You may not hide inside a block! No " + ServerConfig.Currency + " for you."); reward = 0;
} else if (reward > 0) { } else if (reward > 0) {
pl.SendMessage("&6You gained " + reward + " " + ServerConfig.Currency); pl.Message("&6You gained " + reward + " " + ServerConfig.Currency);
} }
pl.SetMoney(pl.money + reward); pl.SetMoney(pl.money + reward);
@ -303,7 +303,7 @@ namespace MCGalaxy.Games {
pl.Game.PledgeSurvive = false; pl.Game.PledgeSurvive = false;
if (pl.Game.Referee) { if (pl.Game.Referee) {
pl.SendMessage("You gained one " + ServerConfig.Currency + " because you're a ref. Would you like a medal as well?"); pl.Message("You gained one " + ServerConfig.Currency + " because you're a ref. Would you like a medal as well?");
pl.SetMoney(pl.money + 1); pl.SetMoney(pl.money + 1);
} }

View File

@ -55,13 +55,13 @@ namespace MCGalaxy {
} }
public bool CheckDetailed(Player p, bool ignoreRankPerm = false) { public bool CheckDetailed(Player p, bool ignoreRankPerm = false) {
AccessResult result = Check(p); AccessResult access = Check(p);
if (result == AccessResult.Allowed) return true; if (access == AccessResult.Allowed) return true;
if (result == AccessResult.Whitelisted) return true; if (access == AccessResult.Whitelisted) return true;
if (result == AccessResult.AboveMaxRank && ignoreRankPerm) return true; if (access == AccessResult.AboveMaxRank && ignoreRankPerm) return true;
if (result == AccessResult.BelowMinRank && ignoreRankPerm) return true; if (access == AccessResult.BelowMinRank && ignoreRankPerm) return true;
if (result == AccessResult.Blacklisted) { if (access == AccessResult.Blacklisted) {
p.Message("You are blacklisted from {0} {1}", ActionIng, ColoredName); p.Message("You are blacklisted from {0} {1}", ActionIng, ColoredName);
return false; return false;
} }
@ -71,10 +71,10 @@ namespace MCGalaxy {
whitelist = "(and " + Whitelisted.Join(pl => PlayerInfo.GetColoredName(p, pl)) + "%S) "; whitelist = "(and " + Whitelisted.Join(pl => PlayerInfo.GetColoredName(p, pl)) + "%S) ";
} }
if (result == AccessResult.BelowMinRank) { if (access == AccessResult.BelowMinRank) {
p.Message("Only {2}%S+ {3}may {0} {1}", p.Message("Only {2}%S+ {3}may {0} {1}",
Action, ColoredName, Group.GetColoredName(Min), whitelist); Action, ColoredName, Group.GetColoredName(Min), whitelist);
} else if (result == AccessResult.AboveMaxRank) { } else if (access == AccessResult.AboveMaxRank) {
p.Message("Only {2} %Sand below {3}may {0} {1}", p.Message("Only {2} %Sand below {3}may {0} {1}",
Action, ColoredName, Group.GetColoredName(Max), whitelist); Action, ColoredName, Group.GetColoredName(Max), whitelist);
} }
@ -104,29 +104,29 @@ namespace MCGalaxy {
} }
public bool SetMin(Player p, Level lvl, Group grp) { public bool SetMin(Player p, LevelPermission plRank, Level lvl, Group grp) {
string minType = "Min " + Type; string minType = "Min " + Type;
if (!CheckRank(p, Min, minType, false)) return false; if (!CheckRank(p, plRank, Min, minType, false)) return false;
if (!CheckRank(p, grp.Permission, minType, true)) return false; if (!CheckRank(p, plRank, grp.Permission, minType, true)) return false;
Min = grp.Permission; Min = grp.Permission;
OnPermissionChanged(p, lvl, grp, minType); OnPermissionChanged(p, lvl, grp, minType);
return true; return true;
} }
public bool SetMax(Player p, Level lvl, Group grp) { public bool SetMax(Player p, LevelPermission plRank, Level lvl, Group grp) {
string maxType = "Max " + Type; string maxType = "Max " + Type;
const LevelPermission ignore = LevelPermission.Nobody; const LevelPermission ignore = LevelPermission.Nobody;
if (Max != ignore && !CheckRank(p, Max, maxType, false)) return false; if (Max != ignore && !CheckRank(p, plRank, Max, maxType, false)) return false;
if (grp.Permission != ignore && !CheckRank(p, grp.Permission, maxType, true)) return false; if (grp.Permission != ignore && !CheckRank(p, plRank, grp.Permission, maxType, true)) return false;
Max = grp.Permission; Max = grp.Permission;
OnPermissionChanged(p, lvl, grp, maxType); OnPermissionChanged(p, lvl, grp, maxType);
return true; return true;
} }
public bool Whitelist(Player p, Level lvl, string target) { public bool Whitelist(Player p, LevelPermission plRank, Level lvl, string target) {
if (!CheckList(p, target, true)) return false; if (!CheckList(p, plRank, target, true)) return false;
if (Whitelisted.CaselessContains(target)) { if (Whitelisted.CaselessContains(target)) {
p.Message("{0} %Sis already whitelisted.", PlayerInfo.GetColoredName(p, target)); p.Message("{0} %Sis already whitelisted.", PlayerInfo.GetColoredName(p, target));
return true; return true;
@ -141,8 +141,8 @@ namespace MCGalaxy {
return true; return true;
} }
public bool Blacklist(Player p, Level lvl, string target) { public bool Blacklist(Player p, LevelPermission plRank, Level lvl, string target) {
if (!CheckList(p, target, false)) return false; if (!CheckList(p, plRank, target, false)) return false;
if (Blacklisted.CaselessContains(target)) { if (Blacklisted.CaselessContains(target)) {
p.Message("{0} %Sis already blacklisted.", PlayerInfo.GetColoredName(p, target)); p.Message("{0} %Sis already blacklisted.", PlayerInfo.GetColoredName(p, target));
return true; return true;
@ -175,8 +175,8 @@ namespace MCGalaxy {
protected abstract void ApplyChanges(Player p, Level lvl, string msg); protected abstract void ApplyChanges(Player p, Level lvl, string msg);
bool CheckRank(Player p, LevelPermission perm, string type, bool newPerm) { bool CheckRank(Player p, LevelPermission plRank, LevelPermission perm, string type, bool newPerm) {
if (perm <= p.Rank) return true; if (perm <= plRank) return true;
p.Message("You cannot change the {0} rank of {1}{2} higher than yours.", p.Message("You cannot change the {0} rank of {1}{2} higher than yours.",
type.ToLower(), ColoredName, type.ToLower(), ColoredName,
@ -186,14 +186,14 @@ namespace MCGalaxy {
/// <summary> Returns true if the player is allowed to modify these access permissions, /// <summary> Returns true if the player is allowed to modify these access permissions,
/// and is also allowed to change the access permissions for the target player. </summary> /// and is also allowed to change the access permissions for the target player. </summary>
bool CheckList(Player p, string name, bool whitelist) { bool CheckList(Player p, LevelPermission plRank, string name, bool whitelist) {
if (p != null && !CheckDetailed(p)) { if (p != null && !CheckDetailed(p)) {
string mode = whitelist ? "whitelist" : "blacklist"; string mode = whitelist ? "whitelist" : "blacklist";
p.Message("Hence you cannot modify the {0} {1}.", Type, mode); return false; p.Message("Hence you cannot modify the {0} {1}.", Type, mode); return false;
} }
Group group = PlayerInfo.GetGroup(name); Group group = PlayerInfo.GetGroup(name);
if (group.Permission <= p.Rank) return true; if (group.Permission <= plRank) return true;
if (!whitelist) { if (!whitelist) {
p.Message("You cannot blacklist players of a higher rank."); p.Message("You cannot blacklist players of a higher rank.");

View File

@ -218,9 +218,9 @@ namespace MCGalaxy {
if (!announce) return; if (!announce) return;
if (src == null || !Entities.CanSee(p, src)) { if (src == null || !Entities.CanSee(p, src)) {
p.SendMessage("&bMap reloaded"); p.Message("&bMap reloaded");
} else { } else {
p.SendMessage("&bMap reloaded by " + src.ColoredName); p.Message("&bMap reloaded by " + src.ColoredName);
} }
if (Entities.CanSee(src, p)) { if (Entities.CanSee(src, p)) {
src.Message("&4Finished reloading for " + p.ColoredName); src.Message("&4Finished reloading for " + p.ColoredName);

View File

@ -137,10 +137,10 @@ namespace MCGalaxy {
return cfg; return cfg;
} }
internal static bool ValidateAction(Player p, string map, string action) { internal static bool ValidateAction(Player p, CommandData data, string map, string action) {
if (p == null) return true; if (p == null) return true;
Level lvl; LevelConfig cfg = GetConfig(map, out lvl); Level lvl; LevelConfig cfg = GetConfig(map, out lvl);
if (lvl != null) return ValidateAction(p, lvl, action); if (lvl != null) return ValidateAction(p, data, lvl, action);
LevelAccessController visit = new LevelAccessController(cfg, map, true); LevelAccessController visit = new LevelAccessController(cfg, map, true);
LevelAccessController build = new LevelAccessController(cfg, map, false); LevelAccessController build = new LevelAccessController(cfg, map, false);
@ -150,7 +150,7 @@ namespace MCGalaxy {
return true; return true;
} }
internal static bool ValidateAction(Player p, Level lvl, string action) { internal static bool ValidateAction(Player p, CommandData data, Level lvl, string action) {
if (p == null) return true; if (p == null) return true;
if (!lvl.VisitAccess.CheckDetailed(p) || !lvl.BuildAccess.CheckDetailed(p)) { if (!lvl.VisitAccess.CheckDetailed(p) || !lvl.BuildAccess.CheckDetailed(p)) {
p.Message("Hence, you cannot {0}.", action); return false; p.Message("Hence, you cannot {0}.", action); return false;

View File

@ -222,7 +222,7 @@ namespace MCGalaxy {
} catch (Exception ex) { } catch (Exception ex) {
success = false; success = false;
PlayerActions.ChangeMap(this, Server.mainLevel); PlayerActions.ChangeMap(this, Server.mainLevel);
SendMessage("%WThere was an error sending the map, you have been sent to the main level."); Message("%WThere was an error sending the map, you have been sent to the main level.");
Logger.LogError(ex); Logger.LogError(ex);
} finally { } finally {
Server.DoGC(); Server.DoGC();

View File

@ -95,6 +95,7 @@ namespace MCGalaxy {
public bool trainGrab; public bool trainGrab;
public bool onTrain, trainInvincible; public bool onTrain, trainInvincible;
int mbRecursion;
public bool frozen; public bool frozen;
public string following = ""; public string following = "";

View File

@ -50,7 +50,7 @@ namespace MCGalaxy {
if (jailed || frozen || !canBuild) { RevertBlock(x, y, z); return; } if (jailed || frozen || !canBuild) { RevertBlock(x, y, z); return; }
if (!agreed) { if (!agreed) {
SendMessage(mustAgreeMsg); Message(mustAgreeMsg);
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
@ -58,12 +58,12 @@ namespace MCGalaxy {
bool deletingBlock = !painting && !placing; bool deletingBlock = !painting && !placing;
if (ServerConfig.verifyadmins && adminpen) { if (ServerConfig.verifyadmins && adminpen) {
SendMessage("%WYou must first verify with %T/Pass [Password]"); Message("%WYou must first verify with %T/Pass [Password]");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
if ( LSGame.Instance.Running && LSGame.Instance.Map == level && LSGame.Instance.IsPlayerDead(this) ) { if ( LSGame.Instance.Running && LSGame.Instance.Map == level && LSGame.Instance.IsPlayerDead(this) ) {
SendMessage("You are out of the round, and cannot build."); Message("You are out of the round, and cannot build.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
@ -73,7 +73,7 @@ namespace MCGalaxy {
if (cancelBlock) { cancelBlock = false; return; } if (cancelBlock) { cancelBlock = false; return; }
if (old >= Block.Air_Flood && old <= Block.Door_Air_air) { if (old >= Block.Air_Flood && old <= Block.Door_Air_air) {
SendMessage("Block is active, you cannot disturb it."); Message("Block is active, you cannot disturb it.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
@ -89,7 +89,7 @@ namespace MCGalaxy {
if (diff > ReachDistance + 4) { if (diff > ReachDistance + 4) {
Logger.Log(LogType.Warning, "{0} attempted to build with a {1} distance offset", name, diff); Logger.Log(LogType.Warning, "{0} attempted to build with a {1} distance offset", name, diff);
SendMessage("You can't build that far away."); Message("You can't build that far away.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
} }
@ -282,16 +282,16 @@ namespace MCGalaxy {
RawHeldBlock = held; RawHeldBlock = held;
if ((action == 0 || held == Block.Air) && !level.Config.Deletable) { if ((action == 0 || held == Block.Air) && !level.Config.Deletable) {
SendMessage("Deleting blocks is disabled in this level."); Message("Deleting blocks is disabled in this level.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} else if (action == 1 && !level.Config.Buildable) { } else if (action == 1 && !level.Config.Buildable) {
SendMessage("Placing blocks is disabled in this level."); Message("Placing blocks is disabled in this level.");
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
if (held >= Block.Extended) { if (held >= Block.Extended) {
if (!hasBlockDefs || level.CustomBlockDefs[held] == null) { if (!hasBlockDefs || level.CustomBlockDefs[held] == null) {
SendMessage("Invalid block type: " + Block.ToRaw(held)); Message("Invalid block type: " + Block.ToRaw(held));
RevertBlock(x, y, z); return; RevertBlock(x, y, z); return;
} }
} }
@ -479,7 +479,7 @@ namespace MCGalaxy {
} }
// People who are muted can't speak or vote // People who are muted can't speak or vote
if (muted) { SendMessage("You are muted."); return; } //Muted: Only allow commands if (muted) { Message("You are muted."); return; } //Muted: Only allow commands
if (Server.voting) { if (Server.voting) {
if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) || if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) ||
@ -490,7 +490,7 @@ namespace MCGalaxy {
if (ZSGame.Instance.HandlesChatMessage(this, text)) return; if (ZSGame.Instance.HandlesChatMessage(this, text)) return;
// Put this after vote collection so that people can vote even when chat is moderated // Put this after vote collection so that people can vote even when chat is moderated
if (Server.chatmod && !voice) { SendMessage("Chat moderation is on, you cannot speak."); return; } if (Server.chatmod && !voice) { Message("Chat moderation is on, you cannot speak."); return; }
// Filter out bad words // Filter out bad words
if (ServerConfig.ProfanityFiltering) text = ProfanityFilter.Parse(text); if (ServerConfig.ProfanityFiltering) text = ProfanityFilter.Parse(text);
@ -524,17 +524,17 @@ namespace MCGalaxy {
} }
if (text.CaselessContains("^detail.user=")) { if (text.CaselessContains("^detail.user=")) {
SendMessage("%WYou cannot use WoM detail strings in a chat message."); Message("%WYou cannot use WoM detail strings in a chat message.");
return true; return true;
} }
if (IsPartialSpaced(text)) { if (IsPartialSpaced(text)) {
partialMessage += text.Substring(0, text.Length - 2) + " "; partialMessage += text.Substring(0, text.Length - 2) + " ";
SendMessage("&3Partial message: &f" + partialMessage); Message("&3Partial message: &f" + partialMessage);
return true; return true;
} else if (IsPartialJoined(text)) { } else if (IsPartialJoined(text)) {
partialMessage += text.Substring(0, text.Length - 2); partialMessage += text.Substring(0, text.Length - 2);
SendMessage("&3Partial message: &f" + partialMessage); Message("&3Partial message: &f" + partialMessage);
return true; return true;
} else if (partialMessage.Length > 0) { } else if (partialMessage.Length > 0) {
text = partialMessage + text; text = partialMessage + text;
@ -601,6 +601,8 @@ namespace MCGalaxy {
public void HandleCommand(string cmd, string args, CommandData data) { public void HandleCommand(string cmd, string args, CommandData data) {
cmd = cmd.ToLower(); cmd = cmd.ToLower();
if (!ServerConfig.CmdSpamCheck && !CheckMBRecursion(data)) return;
try { try {
Command command = GetCommand(ref cmd, ref args, data); Command command = GetCommand(ref cmd, ref args, data);
if (command == null) return; if (command == null) return;
@ -610,13 +612,16 @@ namespace MCGalaxy {
thread.IsBackground = true; thread.IsBackground = true;
thread.Start(); thread.Start();
} catch (Exception e) { } catch (Exception e) {
Logger.LogError(e); SendMessage("Command failed."); Logger.LogError(e);
Message("%WCommand failed");
} }
} }
public void HandleCommands(List<string> cmds, CommandData data) { public void HandleCommands(List<string> cmds, CommandData data) {
List<string> messages = new List<string>(cmds.Count); List<string> messages = new List<string>(cmds.Count);
List<Command> commands = new List<Command>(cmds.Count); List<Command> commands = new List<Command>(cmds.Count);
if (!ServerConfig.CmdSpamCheck && !CheckMBRecursion(data)) return;
try { try {
foreach (string raw in cmds) { foreach (string raw in cmds) {
string[] parts = raw.SplitSpaces(2); string[] parts = raw.SplitSpaces(2);
@ -634,27 +639,40 @@ namespace MCGalaxy {
thread.IsBackground = true; thread.IsBackground = true;
thread.Start(); thread.Start();
} catch (Exception e) { } catch (Exception e) {
Logger.LogError(e); SendMessage("%WCommand failed."); Logger.LogError(e);
Message("%WCommand failed.");
} }
} }
bool CheckMBRecursion(CommandData data) {
if (data.Context == CommandContext.MessageBlock) {
mbRecursion++;
// failsafe for when server has turned off command spam checking
if (mbRecursion >= 100) {
mbRecursion = 0;
Message("%WInfinite message block loop detected, aborting");
return false;
}
} else { mbRecursion = 0; }
return true;
}
bool CheckCommand(string cmd) { bool CheckCommand(string cmd) {
if (cmd.Length == 0) { SendMessage("No command entered."); return false; } if (cmd.Length == 0) { Message("No command entered."); return false; }
if (ServerConfig.AgreeToRulesOnEntry && !agreed && !(cmd == "agree" || cmd == "rules" || cmd == "disagree" || cmd == "pass" || cmd == "setpass")) { if (ServerConfig.AgreeToRulesOnEntry && !agreed && !(cmd == "agree" || cmd == "rules" || cmd == "disagree" || cmd == "pass" || cmd == "setpass")) {
SendMessage(mustAgreeMsg); return false; Message(mustAgreeMsg); return false;
} }
if (jailed) { if (jailed) {
SendMessage("You cannot use any commands while jailed."); return false; Message("You cannot use any commands while jailed."); return false;
} }
if (ServerConfig.verifyadmins && adminpen && !(cmd == "pass" || cmd == "setpass")) { if (ServerConfig.verifyadmins && adminpen && !(cmd == "pass" || cmd == "setpass")) {
SendMessage("%WYou must verify first with %T/Pass [Password]"); return false; Message("%WYou must verify first with %T/Pass [Password]"); return false;
} }
TimeSpan delta = cmdUnblocked - DateTime.UtcNow; TimeSpan delta = cmdUnblocked - DateTime.UtcNow;
if (delta.TotalSeconds > 0) { if (delta.TotalSeconds > 0) {
int secs = (int)Math.Ceiling(delta.TotalSeconds); int secs = (int)Math.Ceiling(delta.TotalSeconds);
SendMessage("Blocked from using commands for " + Message("Blocked from using commands for another " + secs + " seconds"); return false;
"another " + secs + " seconds"); return false;
} }
return true; return true;
} }
@ -666,7 +684,7 @@ namespace MCGalaxy {
byte bindIndex; byte bindIndex;
if (byte.TryParse(cmdName, out bindIndex) && bindIndex < CmdBindings.Length) { if (byte.TryParse(cmdName, out bindIndex) && bindIndex < CmdBindings.Length) {
if (CmdArgsBindings[bindIndex] == null) { if (CmdArgsBindings[bindIndex] == null) {
SendMessage("No command is bound to: %T/" + cmdName); return null; Message("No command is bound to: %T/" + cmdName); return null;
} }
cmdName = CmdBindings[bindIndex]; cmdName = CmdBindings[bindIndex];
@ -684,7 +702,7 @@ namespace MCGalaxy {
command = Command.Find("Mode"); command = Command.Find("Mode");
} else { } else {
Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs); Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs);
SendMessage("Unknown command \"" + cmdName + "\"."); return null; Message("Unknown command \"" + cmdName + "\"."); return null;
} }
} }
@ -695,13 +713,13 @@ namespace MCGalaxy {
string reason = Command.GetDisabledReason(command.Enabled); string reason = Command.GetDisabledReason(command.Enabled);
if (reason != null) { if (reason != null) {
SendMessage("Command is disabled as " + reason); return null; Message("Command is disabled as " + reason); return null;
} }
if (level.IsMuseum && !command.museumUsable) { if (level.IsMuseum && !command.museumUsable) {
SendMessage("Cannot use this command while in a museum."); return null; Message("Cannot use this command while in a museum."); return null;
} }
if (frozen && !command.UseableWhenFrozen) { if (frozen && !command.UseableWhenFrozen) {
SendMessage("Cannot use this command while frozen."); return null; Message("Cannot use this command while frozen."); return null;
} }
return command; return command;
} }

View File

@ -112,7 +112,7 @@ namespace MCGalaxy {
if (Server.noEmotes.Contains(name)) { parseEmotes = !ServerConfig.ParseEmotes; } if (Server.noEmotes.Contains(name)) { parseEmotes = !ServerConfig.ParseEmotes; }
hidden = group.CanExecute("Hide") && Server.hidden.Contains(name); hidden = group.CanExecute("Hide") && Server.hidden.Contains(name);
if (hidden) SendMessage("&8Reminder: You are still hidden."); if (hidden) Message("&8Reminder: You are still hidden.");
if (Chat.AdminchatPerms.UsableBy(Rank) && ServerConfig.AdminsJoinSilently) { if (Chat.AdminchatPerms.UsableBy(Rank) && ServerConfig.AdminsJoinSilently) {
hidden = true; adminchat = true; hidden = true; adminchat = true;
@ -129,26 +129,26 @@ namespace MCGalaxy {
} }
if (ServerConfig.AgreeToRulesOnEntry && Rank == LevelPermission.Guest && !Server.agreed.Contains(name)) { if (ServerConfig.AgreeToRulesOnEntry && Rank == LevelPermission.Guest && !Server.agreed.Contains(name)) {
SendMessage("&9You must read the &c/Rules &9and &c/Agree &9to them before you can build and use commands!"); Message("&9You must read the &c/Rules &9and &c/Agree &9to them before you can build and use commands!");
agreed = false; agreed = false;
} }
if (ServerConfig.verifyadmins && Rank >= ServerConfig.VerifyAdminsRank) { if (ServerConfig.verifyadmins && Rank >= ServerConfig.VerifyAdminsRank) {
if (!Directory.Exists("extra/passwords") || !File.Exists("extra/passwords/" + name + ".dat")) if (!Directory.Exists("extra/passwords") || !File.Exists("extra/passwords/" + name + ".dat"))
SendMessage("%WPlease set your admin verification password with %T/SetPass [Password]!"); Message("%WPlease set your admin verification password with %T/SetPass [Password]!");
else else
SendMessage("%Wcomplete admin verification with %T/Pass [Password]!"); Message("%Wcomplete admin verification with %T/Pass [Password]!");
} }
if (group.CanExecute("Inbox") && Database.TableExists("Inbox" + name)) { if (group.CanExecute("Inbox") && Database.TableExists("Inbox" + name)) {
int count = Database.CountRows("Inbox" + name); int count = Database.CountRows("Inbox" + name);
if (count > 0) { if (count > 0) {
SendMessage("You have &a" + count + " %Smessages in %T/Inbox"); Message("You have &a" + count + " %Smessages in %T/Inbox");
} }
} }
if (ServerConfig.PositionUpdateInterval > 1000) if (ServerConfig.PositionUpdateInterval > 1000)
SendMessage("Lowlag mode is currently &aON."); Message("Lowlag mode is currently &aON.");
if (String.IsNullOrEmpty(appName)) { if (String.IsNullOrEmpty(appName)) {
Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", name, ip); Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", name, ip);
@ -221,10 +221,10 @@ namespace MCGalaxy {
if (raw == null) { if (raw == null) {
PlayerData.Create(this); PlayerData.Create(this);
Chat.MessageFrom(this, "λNICK %Shas connected for the first time!"); Chat.MessageFrom(this, "λNICK %Shas connected for the first time!");
SendMessage("Welcome " + ColoredName + "%S! This is your first visit."); Message("Welcome " + ColoredName + "%S! This is your first visit.");
} else { } else {
PlayerData.Apply((PlayerData)raw, this); PlayerData.Apply((PlayerData)raw, this);
SendMessage("Welcome back " + FullName + "%S! You've been here " + TimesVisited + " times!"); Message("Welcome back " + FullName + "%S! You've been here " + TimesVisited + " times!");
} }
gotSQLData = true; gotSQLData = true;
} }