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