Use X.Parse instead of Convert.Y in more places

This commit is contained in:
UnknownShadow200 2016-08-29 14:32:28 +10:00
parent 87effa41d8
commit eee95f7a10
5 changed files with 25 additions and 26 deletions

View File

@ -40,19 +40,19 @@ namespace MCGalaxy.Bots {
switch (args[0].ToLower()) {
case "walk":
case "teleport":
newPos.x = Convert.ToUInt16(args[1]);
newPos.y = Convert.ToUInt16(args[2]);
newPos.z = Convert.ToUInt16(args[3]);
newPos.rotx = Convert.ToByte(args[4]);
newPos.roty = Convert.ToByte(args[5]);
newPos.x = ushort.Parse(args[1]);
newPos.y = ushort.Parse(args[2]);
newPos.z = ushort.Parse(args[3]);
newPos.rotx = byte.Parse(args[4]);
newPos.roty = byte.Parse(args[5]);
break;
case "wait":
case "speed":
newPos.seconds = Convert.ToInt16(args[1]); break;
newPos.seconds = short.Parse(args[1]); break;
case "nod":
case "spin":
newPos.seconds = Convert.ToInt16(args[1]);
newPos.rotspeed = Convert.ToInt16(args[2]);
newPos.seconds = short.Parse(args[1]);
newPos.rotspeed = short.Parse(args[2]);
break;
case "linkscript":
newPos.newscript = args[1]; break;

View File

@ -42,10 +42,9 @@ namespace MCGalaxy.Commands {
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]);
DateTime timeRanked = new DateTime(years, months, days, hours, minutes, 0);
int min = int.Parse(parts[2]), hour = int.Parse(parts[3]);
int day = int.Parse(parts[4]), month = int.Parse(parts[5]), year = int.Parse(parts[6]);
DateTime timeRanked = new DateTime(year, month, day, hour, min, 0);
string reason = parts.Length <= 9 ? "(no reason given)" :
CP437Reader.ConvertToRaw(parts[9].Replace("%20", " "));

View File

@ -45,9 +45,9 @@ namespace MCGalaxy.Commands {
Player.Message(p, who.ColoredName + " %Shas been exploded!");
} else if (args.Length == 3) {
try {
x = Convert.ToUInt16(args[0]);
y = Convert.ToUInt16(args[1]);
z = Convert.ToUInt16(args[2]);
x = ushort.Parse(args[0]);
y = ushort.Parse(args[1]);
z = ushort.Parse(args[2]);
} catch {
Player.Message(p, "Invalid parameters"); return;
}

View File

@ -37,15 +37,15 @@ namespace MCGalaxy.Commands.Building {
case 1: block = message == "" ? block :
DrawCmd.GetBlock(p, parts[0], out extBlock); break;
case 3:
x = (ushort)(Convert.ToUInt16(parts[0]) * 32);
y = (ushort)(Convert.ToUInt16(parts[1]) * 32);
z = (ushort)(Convert.ToUInt16(parts[2]) * 32);
x = (ushort)(ushort.Parse(parts[0]) * 32);
y = (ushort)(ushort.Parse(parts[1]) * 32);
z = (ushort)(ushort.Parse(parts[2]) * 32);
break;
case 4:
block = DrawCmd.GetBlock(p, parts[0], out extBlock);
x = (ushort)(Convert.ToUInt16(parts[1]) * 32);
y = (ushort)(Convert.ToUInt16(parts[2]) * 32);
z = (ushort)(Convert.ToUInt16(parts[3]) * 32);
x = (ushort)(ushort.Parse(parts[1]) * 32);
y = (ushort)(ushort.Parse(parts[2]) * 32);
z = (ushort)(ushort.Parse(parts[3]) * 32);
break;
default: Player.Message(p, "Invalid number of parameters"); return;
}

View File

@ -54,12 +54,12 @@ namespace MCGalaxy.Undo {
if (!super && !p.level.name.CaselessEq(map)) continue;
pos.LevelName = map;
pos.X = Convert.ToUInt16(lines[(i * items) - 6]);
pos.Y = Convert.ToUInt16(lines[(i * items) - 5]);
pos.Z = Convert.ToUInt16(lines[(i * items) - 4]);
pos.X = ushort.Parse(lines[(i * items) - 6]);
pos.Y = ushort.Parse(lines[(i * items) - 5]);
pos.Z = ushort.Parse(lines[(i * items) - 4]);
pos.Block = Convert.ToByte(lines[(i * items) - 2]);
pos.NewBlock = Convert.ToByte(lines[(i * items) - 1]);
pos.Block = byte.Parse(lines[(i * items) - 2]);
pos.NewBlock = byte.Parse(lines[(i * items) - 1]);
yield return pos;
}
}