Fix /rankinfo throwing NullReferenceException when someone was promoted/demoted to a rank in the past that no longer exists. (Thanks jackhound123)

This commit is contained in:
UnknownShadow200 2016-07-23 12:39:00 +10:00
parent 480d8f65ae
commit 174cd681f8
2 changed files with 10 additions and 9 deletions

View File

@ -19,9 +19,7 @@ using System;
using System.IO;
namespace MCGalaxy.Commands {
public sealed class CmdRankInfo : Command {
public override string name { get { return "rankinfo"; } }
public override string shortcut { get { return "ri"; } }
public override string type { get { return CommandTypes.Moderation; } }
@ -39,6 +37,9 @@ namespace MCGalaxy.Commands {
foreach (string line in Server.RankInfo.Find(target)) {
string[] parts = line.Split(' ');
Group newRank = Group.Find(parts[7]), oldRank = Group.Find(parts[8]);
string newRankName = newRank == null ? parts[7] : newRank.ColoredName;
string oldRankName = oldRank == null ? parts[8] : oldRank.ColoredName;
int minutes = Convert.ToInt32(parts[2]), hours = Convert.ToInt32(parts[3]);
int days = Convert.ToInt32(parts[4]), months = Convert.ToInt32(parts[5]);
int years = Convert.ToInt32(parts[6]);
@ -47,7 +48,7 @@ namespace MCGalaxy.Commands {
CP437Reader.ConvertToRaw(parts[9].Replace("%20", " "));
Player.Message(p, "&aFrom {0} &ato {1} &aon %S{2}",
oldRank.ColoredName, newRank.ColoredName, timeRanked);
oldRankName, newRankName, timeRanked);
Player.Message(p, "&aBy %S{0} &a, reason: %S{1}", parts[1], reason);
found = true;
}

View File

@ -64,13 +64,13 @@ namespace MCGalaxy.Commands.Building {
public override void Help(Player p) {
Player.Message(p, "%T/brush [name] <default brush args>");
Player.Message(p, "%HSets your current brush to the brush with the given name.");
Player.Message(p, "%HSets your current brush to the brush with that name.");
Player.Message(p, "%T/help brush [name]");
Player.Message(p, "%HOutputs the help for the brush with the given name.");
Player.Message(p, "%HOutputs the help for the brush with that name.");
Player.Message(p, "%HAvailable brushes: %S" + AvailableBrushes);
Player.Message(p, "%H The default brush takes one argument specifying the block to draw with. " +
Player.Message(p, "%H- The default brush takes one argument specifying the block to draw with. " +
"If no arguments are given, draws with your currently held block.");
Player.Message(p, "%H If \"skip\" is used for a block name, " +
Player.Message(p, "%H- If \"skip\" is used for a block name, " +
"existing blocks in the map will not be replaced by this block.");
}