This commit is contained in:
UnknownShadow200 2017-02-28 23:15:20 +11:00
parent b6debbd8e9
commit 27b3b0950d
6 changed files with 29 additions and 27 deletions

View File

@ -84,8 +84,8 @@ namespace MCGalaxy {
public static Dictionary<string, string> CustomTokens = new Dictionary<string, string>();
internal static void LoadCustom() {
CustomTokens.Clear();
if (File.Exists("text/custom$s.txt")) {
using (StreamReader r = new StreamReader("text/custom$s.txt")) {
if (File.Exists(Paths.CustomTokensFile)) {
using (StreamReader r = new StreamReader(Paths.CustomTokensFile)) {
string line;
while ((line = r.ReadLine()) != null) {
if (line.StartsWith("//")) continue;
@ -96,7 +96,7 @@ namespace MCGalaxy {
}
} else {
Server.s.Log("custom$s.txt does not exist, creating");
using (StreamWriter w = new StreamWriter("text/custom$s.txt")) {
using (StreamWriter w = new StreamWriter(Paths.CustomTokensFile)) {
w.WriteLine("// This is used to create custom $s");
w.WriteLine("// If you start the line with a // it wont be used");
w.WriteLine("// It should be formatted like this:");

View File

@ -228,19 +228,11 @@ namespace MCGalaxy {
Player[] players = PlayerInfo.Online.Items;
foreach (Player p in players) {
if (!p.HasCpeExt(CpeExt.TextColors)) continue;
SendSetTextColor(p, col);
p.Send(Packet.SetTextColor(col));
}
SaveExtColors();
}
internal static void SendSetTextColor(Player p, CustomColor col) {
byte[] buffer = new byte[6];
buffer[0] = Opcode.CpeSetTextColor;
buffer[1] = col.R; buffer[2] = col.G; buffer[3] = col.B; buffer[4] = col.A;
buffer[5] = (byte)col.Code;
p.Send(buffer);
}
internal static void SaveExtColors() {
using (StreamWriter w = new StreamWriter(Paths.CustomColorsFile)) {
foreach (CustomColor col in ExtColors) {

View File

@ -66,15 +66,15 @@ namespace MCGalaxy {
}
static void LoadBadWords() {
if (!File.Exists("text/badwords.txt")) {
if (!File.Exists(Paths.BadWordsFile)) {
// No file exists yet, so let's create one
StringBuilder sb = new StringBuilder();
sb.AppendLine("# This file contains a list of bad words to remove via the profanity filter");
sb.AppendLine("# Each bad word should be on a new line all by itself");
File.WriteAllText("text/badwords.txt", sb.ToString());
File.WriteAllText(Paths.BadWordsFile, sb.ToString());
}
string[] lines = File.ReadAllLines("text/badwords.txt");
string[] lines = File.ReadAllLines(Paths.BadWordsFile);
// Run the badwords through the reducer to ensure things like Ls become Is and everything is lowercase
filters = new List<string>();
foreach (string line in lines) {

View File

@ -211,6 +211,14 @@ namespace MCGalaxy {
return buffer;
}
public static byte[] SetTextColor(CustomColor col) {
byte[] buffer = new byte[6];
buffer[0] = Opcode.CpeSetTextColor;
buffer[1] = col.R; buffer[2] = col.G; buffer[3] = col.B; buffer[4] = col.A;
buffer[5] = (byte)col.Code;
return buffer;
}
public static byte[] EnvMapUrl(string url, bool hasCP437) {
byte[] buffer = new byte[65];

View File

@ -82,8 +82,9 @@ namespace MCGalaxy {
for (int i = 0; i < Colors.ExtColors.Length; i++) {
if (Colors.ExtColors[i].Undefined) continue;
Colors.SendSetTextColor(this, Colors.ExtColors[i]);
} break;
Send(Packet.SetTextColor(Colors.ExtColors[i]));
}
break;
case CpeExt.BulkBlockUpdate:
BulkBlockUpdate = version; break;
case CpeExt.EnvMapAspect:

View File

@ -16,9 +16,6 @@
permissions and limitations under the Licenses.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MCGalaxy {
@ -29,5 +26,9 @@ namespace MCGalaxy {
public const string BlockPermsFile = "properties/block.properties";
public const string TempRanksFile = "text/tempranks.txt";
public const string CustomTokensFile = "text/custom$s.txt";
public const string BadWordsFile = "text/badwords.txt";
}
}