mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
cleanup
This commit is contained in:
parent
b6debbd8e9
commit
27b3b0950d
@ -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:");
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -53,7 +53,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static byte[] TextHotKey(string label, string input, int keycode,
|
||||
byte mods, bool hasCP437) {
|
||||
byte mods, bool hasCP437) {
|
||||
byte[] buffer = new byte[134];
|
||||
buffer[0] = Opcode.CpeSetTextHotkey;
|
||||
NetUtils.Write(label, buffer, 1, hasCP437);
|
||||
@ -62,8 +62,8 @@ namespace MCGalaxy {
|
||||
buffer[133] = mods;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static byte[] ExtAddEntity(byte id, string name, string displayname, bool hasCP437) {
|
||||
|
||||
public static byte[] ExtAddEntity(byte id, string name, string displayname, bool hasCP437) {
|
||||
byte[] buffer = new byte[130];
|
||||
buffer[0] = Opcode.CpeExtAddEntity;
|
||||
buffer[1] = id;
|
||||
@ -73,7 +73,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static byte[] ExtAddPlayerName(byte id, string listName, string displayName,
|
||||
string grp, byte grpRank, bool hasCP437) {
|
||||
string grp, byte grpRank, bool hasCP437) {
|
||||
byte[] buffer = new byte[196];
|
||||
buffer[0] = Opcode.CpeExtAddPlayerName;
|
||||
NetUtils.WriteI16(id, buffer, 1);
|
||||
@ -151,7 +151,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static byte[] MapAppearance(string url, byte side, byte edge, int sideLevel,
|
||||
bool hasCP437) {
|
||||
bool hasCP437) {
|
||||
byte[] buffer = new byte[69];
|
||||
WriteMapAppearance(buffer, url, side, edge, sideLevel, hasCP437);
|
||||
return buffer;
|
||||
@ -167,7 +167,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
static void WriteMapAppearance(byte[] buffer, string url, byte side, byte edge,
|
||||
int sideLevel, bool hasCP437) {
|
||||
int sideLevel, bool hasCP437) {
|
||||
buffer[0] = Opcode.CpeEnvSetMapApperance;
|
||||
NetUtils.Write(url, buffer, 1, hasCP437);
|
||||
buffer[65] = side;
|
||||
@ -210,6 +210,14 @@ namespace MCGalaxy {
|
||||
buffer[137] = roty;
|
||||
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) {
|
||||
|
@ -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:
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user