Skip to content

Commit

Permalink
Remove unnecessary Split() calls
Browse files Browse the repository at this point in the history
  • 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
Original file line number Diff line number Diff line change
Expand Up @@ -1588,17 +1588,20 @@ static void CustomBlockDefineHandler(Player p, string args, bool global, BlockDe
step = 10;
break;
}
if (args.Split().Length != 3) {

string[] minArgs = args.Split();
if (minArgs.Length != 3) {
p.Message("Please specify 3 coordinates");
return;
}

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

byte maxx, maxy, maxz;
if (byte.TryParse(args.Split()[0], out maxx)
&& byte.TryParse(args.Split()[1], out maxy)
&& byte.TryParse(args.Split()[2], out maxz)
&& (maxx <= 16 && maxx >= 1)
&& (maxy <= 16 && maxy >= 1)
&& (maxz <= 16 && maxz >= 1)) {
if (byte.TryParse(maxArgs[0], out maxx)
&& byte.TryParse(maxArgs[1], out maxy)
&& byte.TryParse(maxArgs[2], out maxz)
&& (maxx >= 1 && maxx <= 16)
&& (maxy >= 1 && maxy <= 16)
&& (maxz >= 1 && maxz <= 16)) {
} else {
p.Message("Invalid coordinates! All 3 must be between 1 and 16");
return;
Expand Down Expand Up @@ -1932,23 +1937,28 @@ static void CustomBlockEditHandler(Player p, CommandReader cmd, bool global, Blo
hasChanged = true;
break;
}
if (args.Split().Length != 3) {

string[] minArgs = args.Split();
if (minArgs.Length != 3) {
p.Message("Please specify 3 coordinates!");
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.MinZ = EditCoord(p, "min Z", def.Name, args.Split()[2], def.MinZ, ref hasChanged);

def.MinX = EditCoord(p, "min X", def.Name, minArgs[0], def.MinX, 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;
break;
case "max":
if (args.Split().Length != 3) {
string[] maxArgs = args.Split();
if (maxArgs.Length != 3) {
p.Message("Please specify 3 coordinates!");
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.MaxZ = EditCoord(p, "max Z", def.Name, args.Split()[2], def.MaxZ, ref hasChanged);

def.MaxX = EditCoord(p, "max X", def.Name, maxArgs[0], def.MaxX, 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;
break;
case "minx":
Expand Down
3 changes: 1 addition & 2 deletions fCraft/System/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ internal static void MarkLogStart() {
public static void LogToConsole( [NotNull] string message ) {
if( message == null ) throw new ArgumentNullException( "message" );
if( message.Contains( "&N" ) ) {
foreach( string line in message.Split( split,
StringSplitOptions.RemoveEmptyEntries ) ) {
foreach( string line in message.Split( split, StringSplitOptions.RemoveEmptyEntries ) ) {
LogToConsole( line );
}
return;
Expand Down
4 changes: 1 addition & 3 deletions fCraft/System/Utils/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ internal ReleaseInfo( int version, int revision, DateTime releaseDate, [NotNull]
Revision = revision;
Date = releaseDate;
Summary = summary;
ChangeLog = changeLog.Split( new[] {
'\n'
} );
ChangeLog = changeLog.Split( new[] { '\n' } );
Flags = releaseType;
}

Expand Down

0 comments on commit d3fd25f

Please sign in to comment.