Skip to content
Permalink
Browse files

Fix for lowercase N color code

  • Loading branch information...
UnknownShadow200 committed May 20, 2017
1 parent e5bfd94 commit 695964996eb12f4c917858da31063ca4fc43929a
@@ -3080,7 +3080,6 @@ static void WorldClearHandler(Player player, CommandReader cmd)
File.Delete("./WorldGreeting/" + world.Name + ".txt");
world.Greeting = null;
} else {
world.Greeting = value.Replace("%n", "/n");
player.Message("Greeting message for world {0}&S set to: {1}", world.ClassyName, world.Greeting);
File.WriteAllText("./WorldGreeting/" + world.Name + ".txt", world.Greeting);
world.Greeting = null;
@@ -272,7 +272,7 @@ static void SignAddHandler(Player player, CommandReader cmd)
{
if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
File.WriteAllText("./Signs/" + player.World.Name + "/" + newZone.Name + ".txt", cmd.NextAll().Replace("%n", "/n"));
File.WriteAllText("./Signs/" + player.World.Name + "/" + newZone.Name + ".txt", cmd.NextAll());
player.Message("Message for sign {0}&S is: {1}", newZone.ClassyName, newZone.Sign);
newZone.Sign = null;
}
@@ -384,7 +384,7 @@ static void SignAddCallback(Player player, Vector3I[] marks, object tag)
{
if (!Directory.Exists("./Signs/")) Directory.CreateDirectory("./Signs/");
if (!Directory.Exists("./Signs/" + player.World.Name + "/")) Directory.CreateDirectory("./Signs/" + player.World.Name + "/");
File.WriteAllText("./Signs/" + player.World.Name + "/" + zone.Name + ".txt", cmd.NextAll().Substring(1).Replace("%n", "/n"));
File.WriteAllText("./Signs/" + player.World.Name + "/" + zone.Name + ".txt", cmd.NextAll().Substring(1));
player.Message("Sign Text for zone {0}&S changed to {1}", zone.ClassyName, zone.Sign);
zone.Sign = null;
}
@@ -850,12 +850,12 @@ public static void SendAction([NotNull] string line)
}


static string[] split = new string[] { "&N", "&n", "\n" };
static string[] split = new string[] { "&N", "\n" };
public static void SendRawMessage(string prefix, [NotNull] string line, string suffix)
{
if (line == null) throw new ArgumentNullException("line");
// handle newlines
if (line.Contains("&N") || line.Contains("&n") || line.Contains("\n"))
if (line.Contains("&N") || line.Contains("\n"))
{
string[] segments = line.Split(split, StringSplitOptions.RemoveEmptyEntries);
SendRawMessage(prefix, segments[0], suffix);
@@ -250,7 +250,7 @@ bool ProcessChar(byte ch)
if (expectingColor)
{
expectingColor = false;
if (ch == 'N' || ch == 'n')
if (ch == 'N')
{
// newline
inputIndex++;
@@ -561,14 +561,13 @@ static bool SendInternal([NotNull] ChatSendingEventArgs e)
return true;
}

/// <summary> Replaces newline codes (&amp;n and &amp;N) with actual newlines (\n). </summary>
/// <summary> Replaces newline codes (&amp;N) with actual newlines (\n). </summary>
/// <param name="message"> Message to process. </param>
/// <returns> Processed message. </returns>
/// <exception cref="ArgumentNullException"> message is null. </exception>
[NotNull, Pure]
public static string ReplaceNewlines( [NotNull] string message ) {
if( message == null ) throw new ArgumentNullException( "message" );
message = message.Replace( "&n", "\n" );
message = message.Replace( "&N", "\n" );
return message;
}
@@ -812,7 +811,7 @@ static void RaiseSentEvent(ChatSendingEventArgs args, int count)
{"grave", '`'}, {"'", '`'}
};

/// <summary> Removes newlines (\n) and newline codes (&amp;n and &amp;N). </summary>
/// <summary> Removes newlines (\n) and newline codes (&amp;N). </summary>
/// <param name="message"> Message to process. </param>
/// <returns> Processed message. </returns>
/// <exception cref="ArgumentNullException"> message is null. </exception>
@@ -821,7 +820,6 @@ public static string StripNewlines([NotNull] string message)
{
if (message == null) throw new ArgumentNullException("message");
message = message.Replace("\n", "");
message = message.Replace("&n", "");
message = message.Replace("&N", "");
return message;
}
@@ -931,7 +929,7 @@ public static string ReplacePercentColorCodes([NotNull] string message, bool all
}
// extract the colorcode
char colorCode = message[startIndex + 1];
if (Color.IsColorCode(colorCode) || allowNewlines && (colorCode == 'n' || colorCode == 'N'))
if (Color.IsColorCode(colorCode) || allowNewlines && colorCode == 'N')
{
if (escaped)
{
@@ -74,13 +74,13 @@ public static class Logger {
}


static string[] split = new string[] { "&N", "&n" };
static string[] split = new string[] { "&N" };
/// <summary> Logs a message of type ConsoleOutput, strips colors,
/// and splits into multiple messages at newlines.
/// Use this method for all messages of LogType.ConsoleOutput </summary>
public static void LogToConsole( [NotNull] string message ) {
if( message == null ) throw new ArgumentNullException( "message" );
if( message.Contains( "&N" ) || message.Contains( "&n" ) ) {
if( message.Contains( "&N" ) ) {
foreach( string line in message.Split( split,
StringSplitOptions.RemoveEmptyEntries ) ) {
LogToConsole( line );

0 comments on commit 6959649

Please sign in to comment.
You can’t perform that action at this time.