Make LineWrapper same spacing as rest of code

This commit is contained in:
UnknownShadow200 2020-06-02 22:03:18 +10:00
parent 5c18fe940d
commit 824fa0853e
4 changed files with 21 additions and 27 deletions

View File

@ -28,36 +28,35 @@ namespace MCGalaxy {
message = Regex.Replace(message, @"(&[0-9a-f])+$", "");
int limit = NetUtils.StringSize; string color = "";
while ( message.Length > 0 ) {
//if (Regex.IsMatch(message, "&a")) break;
while (message.Length > 0) {
if ( lines.Count > 0 ) {
if ( message[0] == '&' )
if (lines.Count > 0 ) {
if (message[0] == '&')
message = "> " + message.Trim();
else
message = "> " + color + message.Trim();
}
if ( message.IndexOf("&") == message.IndexOf("&", message.IndexOf("&") + 1) - 2 )
if (message.IndexOf("&") == message.IndexOf("&", message.IndexOf("&") + 1) - 2)
message = message.Remove(message.IndexOf("&"), 2);
if ( message.Length <= limit ) { lines.Add(message); break; }
for ( int i = limit - 1; i > limit - 20; --i )
if ( message[i] == ' ' ) {
if (message.Length <= limit) { lines.Add(message); break; }
for (int i = limit - 1; i > limit - 20; i--)
if (message[i] == ' ') {
lines.Add(message.Substring(0, i));
goto Next;
}
retry:
if ( message.Length == 0 || limit == 0 ) { return lines; }
if (message.Length == 0 || limit == 0) { return lines; }
try {
if ( message.Substring(limit - 2, 1) == "&" || message.Substring(limit - 1, 1) == "&" ) {
if (message.Substring(limit - 2, 1) == "&" || message.Substring(limit - 1, 1) == "&") {
message = message.Remove(limit - 2, 1);
limit -= 2;
goto retry;
}
else if ( message[limit - 1] < 32 || message[limit - 1] > 127 ) {
else if (message[limit - 1] < 32 || message[limit - 1] > 127) {
message = message.Remove(limit - 1, 1);
limit -= 1;
//goto retry;
@ -67,29 +66,29 @@ namespace MCGalaxy {
lines.Add(message.Substring(0, limit));
Next: message = message.Substring(lines[lines.Count - 1].Length);
if ( lines.Count == 1 ) limit = 60;
if (lines.Count == 1) limit = 60;
int index = lines[lines.Count - 1].LastIndexOf('&');
if ( index != -1 ) {
if ( index < lines[lines.Count - 1].Length - 1 ) {
if (index != -1) {
if (index < lines[lines.Count - 1].Length - 1) {
char next = lines[lines.Count - 1][index + 1];
if ( Colors.Map(ref next) ) color = "&" + next;
if ( index == lines[lines.Count - 1].Length - 1 ) {
if (Colors.Map(ref next)) color = "&" + next;
if (index == lines[lines.Count - 1].Length - 1) {
lines[lines.Count - 1] = lines[lines.Count - 1].Substring(0, lines[lines.Count - 1].Length - 2);
}
}
else if ( message.Length != 0 ) {
else if (message.Length != 0) {
char next = message[0];
if ( Colors.Map(ref next) ) color = "&" + next;
if (Colors.Map(ref next)) color = "&" + next;
lines[lines.Count - 1] = lines[lines.Count - 1].Substring(0, lines[lines.Count - 1].Length - 1);
message = message.Substring(1);
}
}
}
for ( int i = 0; i < lines.Count; i++ ) // Gotta do it the old fashioned way...
for (int i = 0; i < lines.Count; i++) // Gotta do it the old fashioned way...
{
char[] temp = lines[i].ToCharArray();
if ( temp[temp.Length - 2] == '&' ) {
if (temp[temp.Length - 2] == '&') {
temp[temp.Length - 1] = ' ';
temp[temp.Length - 2] = ' ';
}

View File

@ -16,7 +16,6 @@
permissions and limitations under the Licenses.
*/
using System;
using System.Text.RegularExpressions;
using MCGalaxy.SQL;
namespace MCGalaxy.Commands.Chatting {

View File

@ -28,7 +28,6 @@ using MCGalaxy.Network;
using MCGalaxy.SQL;
using MCGalaxy.Util;
using BlockID = System.UInt16;
using BlockRaw = System.Byte;
namespace MCGalaxy {
public partial class Player : IDisposable {

View File

@ -15,19 +15,16 @@ permissions and limitations under the Licenses.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using MCGalaxy.Blocks;
using MCGalaxy.DB;
using MCGalaxy.Drawing;
using MCGalaxy.Events.EconomyEvents;
using MCGalaxy.Events.PlayerEvents;
using MCGalaxy.Games;
using MCGalaxy.SQL;
using MCGalaxy.Network;
using MCGalaxy.Tasks;
using MCGalaxy.Maths;
using MCGalaxy.Network;
using MCGalaxy.SQL;
using BlockID = System.UInt16;
namespace MCGalaxy {