mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-25 22:30:52 -04:00
Core: Fix global.json.bak never actually being saved. (Thanks CookieNetwork)
This commit is contained in:
parent
225c4e5e37
commit
2698973666
@ -124,8 +124,10 @@ namespace MCGalaxy {
|
||||
GlobalProps[i] = new BlockProps((byte)i);
|
||||
|
||||
try {
|
||||
if (File.Exists(GlobalPath) && File.Exists(GlobalBackupPath)) {
|
||||
File.Delete(GlobalBackupPath);
|
||||
if (File.Exists(GlobalPath)) {
|
||||
if (File.Exists(GlobalBackupPath)) {
|
||||
File.Delete(GlobalBackupPath);
|
||||
}
|
||||
File.Copy(GlobalPath, GlobalBackupPath);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -26,7 +26,9 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
for (int i = 0; i < 20; i++) {
|
||||
foreach (Player pl in players) pl.SendBlankMessage();
|
||||
foreach (Player pl in players) {
|
||||
pl.Send(Packet.BlankMessage());
|
||||
}
|
||||
}
|
||||
Chat.MessageAll("%4Global Chat Cleared.");
|
||||
}
|
||||
|
@ -24,8 +24,9 @@ namespace MCGalaxy.Commands {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
for (int i = 0; i < 20; i++)
|
||||
p.SendBlankMessage();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
p.Send(Packet.BlankMessage());
|
||||
}
|
||||
Player.Message(p, "%4Chat cleared.");
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
|
||||
List<string> rules = CP437Reader.ReadAllLines("text/rules.txt");
|
||||
foreach (string rule in rules)
|
||||
AddRule(rule, sections);
|
||||
ParseRule(rule, sections);
|
||||
return sections;
|
||||
}
|
||||
|
||||
static void AddRule(string rule, Dictionary<int, string> sections) {
|
||||
int num = -1;
|
||||
static void ParseRule(string rule, Dictionary<int, string> sections) {
|
||||
int ruleNum = -1;
|
||||
rule = Colors.StripColors(rule);
|
||||
|
||||
for (int i = 0; i < rule.Length; i++) {
|
||||
@ -60,13 +60,14 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
bool isLetter = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
if (!isNumber && !isLetter) continue;
|
||||
// Found start of a word, but didn't find a number - assume this is a non-numbered rule
|
||||
if (isLetter && num == -1) return;
|
||||
if (isLetter && ruleNum == -1) return;
|
||||
|
||||
if (isNumber) { // 1) Do not do X
|
||||
if (num == -1) num = 0;
|
||||
num *= 10; num += (c - '0');
|
||||
if (isNumber) { // e.g. line is: 1) Do not do X
|
||||
if (ruleNum == -1) ruleNum = 0;
|
||||
ruleNum *= 10;
|
||||
ruleNum += (c - '0');
|
||||
} else {
|
||||
sections[num] = rule.Substring(i);
|
||||
sections[ruleNum] = rule.Substring(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,15 @@ namespace MCGalaxy {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static byte[] BlankMessage() {
|
||||
byte[] buffer = new byte[66];
|
||||
buffer[0] = Opcode.Message;
|
||||
|
||||
for (int i = 2; i < buffer.Length; i++)
|
||||
buffer[i] = (byte)' ';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static byte[] UserType(Player p) {
|
||||
byte[] buffer = new byte[2];
|
||||
buffer[0] = Opcode.SetPermission;
|
||||
|
Loading…
x
Reference in New Issue
Block a user