Get rid of Group.concatList and Level.CheckLoadOnGoto

Also less usage of ServerConfig.DefaultColor
This commit is contained in:
UnknownShadow200 2017-06-28 11:05:05 +10:00
parent 80ea964409
commit ff703947e5
8 changed files with 18 additions and 32 deletions

View File

@ -569,7 +569,7 @@ namespace MCGalaxy.Gui {
}
}
{
string mesg = pl.p.ColoredName + ServerConfig.DefaultColor + " " + "is now";
string mesg = pl.p.ColoredName + " %Sis now";
if ( pl.Red ) {
mesg += " on the " + Colors.red + "red team";
}
@ -577,7 +577,7 @@ namespace MCGalaxy.Gui {
mesg += " on the " + Colors.blue + "blue team";
}
if ( pl.spec ) {
mesg += ServerConfig.DefaultColor + " (as a spectator)";
mesg += " (as a spectator)";
}
Chat.MessageGlobal(mesg);
}

View File

@ -172,7 +172,7 @@ namespace MCGalaxy.Commands.Fun {
if (pl.Blue)
msg += " on the " + Colors.blue + "blue team";
if (pl.spec)
msg += ServerConfig.DefaultColor + " (as a spectator)";
msg += " %S(as a spectator)";
Chat.MessageGlobal(msg);
}

View File

@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Info {
public override void Use(Player p, string message) {
string[] args = message.SplitSpaces(2);
if (message == "") {
Player.Message(p, "Available ranks: " + Group.concatList()); return;
Player.Message(p, "Available ranks: " +Group.GroupList.Join(g => g.ColoredName)); return;
}
string modifer = args.Length > 1 ? args[1] : "";
@ -53,7 +53,7 @@ namespace MCGalaxy.Commands.Info {
public override void Help(Player p) {
Player.Message(p, "/viewranks [rank] - Shows all players who have [rank]");
Player.Message(p, "/viewranks banned - Shows all players who are banned.");
Player.Message(p, "Available ranks: " + Group.concatList());
Player.Message(p, "Available ranks: " + Group.GroupList.Join(g => g.ColoredName));
}
}
}

View File

@ -330,7 +330,7 @@ namespace MCGalaxy.Games
if (!votes.ContainsKey(opt) && opt != map.name)
{
votes.Add(opt, 0);
str += ServerConfig.DefaultColor + ", &5" + opt.Capitalize();
str += "%S, &5" + opt.Capitalize();
i++;
}
}
@ -483,7 +483,7 @@ namespace MCGalaxy.Games
{
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, int> kvp in votes)
sb.AppendFormat("{0}, &5{1}", ServerConfig.DefaultColor, kvp.Key.Capitalize());
sb.AppendFormat("%S, &5{0}", kvp.Key.Capitalize());
sb.Remove(0, 4);
return sb.ToString();
}

View File

@ -399,14 +399,6 @@ namespace MCGalaxy {
lvl.UpdateBlockHandlers();
}
public static bool CheckLoadOnGoto(string givenName) {
string value = LevelInfo.FindOfflineProperty(givenName, "loadongoto");
if (value == null) return true;
bool load;
if (!bool.TryParse(value, out load)) return true;
return load;
}
public void ChatLevel(string message) {
ChatLevel(message, LevelPermission.Banned);
}

View File

@ -253,20 +253,6 @@ namespace MCGalaxy {
}
return Group.standard;
}
public static string concatList(bool includeColor = true, bool skipExtra = false, bool permissions = false) {
string sum = "";
foreach (Group grp in Group.GroupList) {
if (skipExtra && (grp.Permission < LevelPermission.Guest || grp.Permission >= LevelPermission.Nobody)) continue;
if (includeColor) sum += ", " + grp.ColoredName + ServerConfig.DefaultColor;
else if (permissions) sum += ", " + ((int)grp.Permission);
else sum += ", " + grp.name;
}
if (includeColor) sum = sum.Remove(sum.Length - 2);
return sum.Remove(0, 2);
}
/// <summary> Returns whether the given player is in the banned rank. </summary>

View File

@ -560,8 +560,8 @@ namespace MCGalaxy {
if ( it.GameMode == TntWarsGame.TntWarsGameMode.TDM ) {
TntWarsGame.player pl = it.FindPlayer(this);
foreach ( TntWarsGame.player p in it.Players ) {
if ( pl.Red && p.Red ) SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- " + ServerConfig.DefaultColor + newtext);
if ( pl.Blue && p.Blue ) SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- " + ServerConfig.DefaultColor + newtext);
if ( pl.Red && p.Red ) SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext);
if ( pl.Blue && p.Blue ) SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext);
}
Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + ( pl.Red ? "Red" : "Blue" ) + ") " + name + " " + newtext);

View File

@ -83,11 +83,19 @@ namespace MCGalaxy {
}
static bool LoadOfflineLevel(Player p, string name) {
if (!Level.CheckLoadOnGoto(name)) {
string propsPath = LevelInfo.FindPropertiesFile(name);
LevelConfig cfg = new LevelConfig();
LevelConfig.Load(propsPath, cfg);
if (!cfg.LoadOnGoto) {
Player.Message(p, "Level \"{0}\" cannot be loaded using /goto.", name);
return false;
}
// LevelAccessController visitAccess = new LevelAccessController(null, cfg, true);
//bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name);
//if (!visitAccess.CheckDetailed(p, ignorePerms)) return false;
CmdLoad.LoadLevel(p, name, true);
Level lvl = LevelInfo.FindExact(name);
if (lvl != null) return GotoLevel(p, lvl);