Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove unnecessary Split() calls
  • Loading branch information
UnknownShadow200 committed Aug 3, 2017
1 parent 48404d8 commit d3fd25f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
54 changes: 32 additions & 22 deletions fCraft/Commands/CpeCommands.cs
Expand Up @@ -1588,17 +1588,20 @@ static class CpeCommands {
step = 10; step = 10;
break; break;
} }
if (args.Split().Length != 3) {
string[] minArgs = args.Split();
if (minArgs.Length != 3) {
p.Message("Please specify 3 coordinates"); p.Message("Please specify 3 coordinates");
return; return;
} }

byte minx, miny, minz; byte minx, miny, minz;
if (byte.TryParse(args.Split()[0], out minx) if (byte.TryParse(minArgs[0], out minx)
&& byte.TryParse(args.Split()[1], out miny) && byte.TryParse(minArgs[1], out miny)
&& byte.TryParse(args.Split()[2], out minz) && byte.TryParse(minArgs[2], out minz)
&& (minx <= 15 && minx >= 0) && (minx >= 0 && minx <= 15)
&& (miny <= 15 && miny >= 0) && (miny >= 0 && miny <= 15)
&& (minz <= 15 && minz >= 0)) { && (minz >= 0 && minz <= 15)) {
} else { } else {
p.Message("Invalid coordinates! All 3 must be between 0 and 15"); p.Message("Invalid coordinates! All 3 must be between 0 and 15");
return; return;
Expand All @@ -1610,17 +1613,19 @@ static class CpeCommands {
p.Message(" &bSet minimum coords to X:{0} Y:{1} Z:{2}", minx, miny, minz); p.Message(" &bSet minimum coords to X:{0} Y:{1} Z:{2}", minx, miny, minz);
break; break;
case 17: case 17:
if (args.Split().Length != 3) { string[] maxArgs = args.Split();
if (maxArgs.Length != 3) {
p.Message("Please specify 3 coordinates"); p.Message("Please specify 3 coordinates");
return; return;
} }

byte maxx, maxy, maxz; byte maxx, maxy, maxz;
if (byte.TryParse(args.Split()[0], out maxx) if (byte.TryParse(maxArgs[0], out maxx)
&& byte.TryParse(args.Split()[1], out maxy) && byte.TryParse(maxArgs[1], out maxy)
&& byte.TryParse(args.Split()[2], out maxz) && byte.TryParse(maxArgs[2], out maxz)
&& (maxx <= 16 && maxx >= 1) && (maxx >= 1 && maxx <= 16)
&& (maxy <= 16 && maxy >= 1) && (maxy >= 1 && maxy <= 16)
&& (maxz <= 16 && maxz >= 1)) { && (maxz >= 1 && maxz <= 16)) {
} else { } else {
p.Message("Invalid coordinates! All 3 must be between 1 and 16"); p.Message("Invalid coordinates! All 3 must be between 1 and 16");
return; return;
Expand Down Expand Up @@ -1932,23 +1937,28 @@ static class CpeCommands {
hasChanged = true; hasChanged = true;
break; break;
} }
if (args.Split().Length != 3) {
string[] minArgs = args.Split();
if (minArgs.Length != 3) {
p.Message("Please specify 3 coordinates!"); p.Message("Please specify 3 coordinates!");
break; break;
} }
def.MinX = EditCoord(p, "min X", def.Name, args.Split()[0], def.MinX, ref hasChanged);
def.MinY = EditCoord(p, "min Y", def.Name, args.Split()[1], def.MinY, ref hasChanged); def.MinX = EditCoord(p, "min X", def.Name, minArgs[0], def.MinX, ref hasChanged);
def.MinZ = EditCoord(p, "min Z", def.Name, args.Split()[2], def.MinZ, ref hasChanged); def.MinY = EditCoord(p, "min Y", def.Name, minArgs[1], def.MinY, ref hasChanged);
def.MinZ = EditCoord(p, "min Z", def.Name, minArgs[2], def.MinZ, ref hasChanged);
hasChanged = true; hasChanged = true;
break; break;
case "max": case "max":
if (args.Split().Length != 3) { string[] maxArgs = args.Split();
if (maxArgs.Length != 3) {
p.Message("Please specify 3 coordinates!"); p.Message("Please specify 3 coordinates!");
break; break;
} }
def.MaxX = EditCoord(p, "max X", def.Name, args.Split()[0], def.MaxX, ref hasChanged);
def.MaxY = EditCoord(p, "max Y", def.Name, args.Split()[1], def.MaxY, ref hasChanged); def.MaxX = EditCoord(p, "max X", def.Name, maxArgs[0], def.MaxX, ref hasChanged);
def.MaxZ = EditCoord(p, "max Z", def.Name, args.Split()[2], def.MaxZ, ref hasChanged); def.MaxY = EditCoord(p, "max Y", def.Name, maxArgs[1], def.MaxY, ref hasChanged);
def.MaxZ = EditCoord(p, "max Z", def.Name, maxArgs[2], def.MaxZ, ref hasChanged);
hasChanged = true; hasChanged = true;
break; break;
case "minx": case "minx":
Expand Down
3 changes: 1 addition & 2 deletions fCraft/System/Logger.cs
Expand Up @@ -81,8 +81,7 @@ public static class Logger {
public static void LogToConsole( [NotNull] string message ) { public static void LogToConsole( [NotNull] string message ) {
if( message == null ) throw new ArgumentNullException( "message" ); if( message == null ) throw new ArgumentNullException( "message" );
if( message.Contains( "&N" ) ) { if( message.Contains( "&N" ) ) {
foreach( string line in message.Split( split, foreach( string line in message.Split( split, StringSplitOptions.RemoveEmptyEntries ) ) {
StringSplitOptions.RemoveEmptyEntries ) ) {
LogToConsole( line ); LogToConsole( line );
} }
return; return;
Expand Down
4 changes: 1 addition & 3 deletions fCraft/System/Utils/Updater.cs
Expand Up @@ -108,9 +108,7 @@ public sealed class ReleaseInfo {
Revision = revision; Revision = revision;
Date = releaseDate; Date = releaseDate;
Summary = summary; Summary = summary;
ChangeLog = changeLog.Split( new[] { ChangeLog = changeLog.Split( new[] { '\n' } );
'\n'
} );
Flags = releaseType; Flags = releaseType;
} }


Expand Down

0 comments on commit d3fd25f

Please sign in to comment.