Don't save global blocks list on server start

also remove some obsolete LS/ZS config stuff
This commit is contained in:
UnknownShadow200 2018-06-20 08:03:02 +10:00
parent 084fc09e5f
commit 7ffa5493ad
11 changed files with 32 additions and 68 deletions

View File

@ -144,7 +144,6 @@ namespace MCGalaxy {
Logger.LogError(ex); Logger.LogError(ex);
} }
Save(true, null);
// As the BlockDefinition instances in levels will now be different // As the BlockDefinition instances in levels will now be different
// to the instances in GlobalDefs, we need to update them. // to the instances in GlobalDefs, we need to update them.
if (oldDefs != null) UpdateLoadedLevels(oldDefs); if (oldDefs != null) UpdateLoadedLevels(oldDefs);

View File

@ -91,14 +91,13 @@ namespace MCGalaxy {
if (who == null) return; if (who == null) return;
if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return; } if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return; }
if (who.Ignores.All) { Logger.Log(LogType.PrivateChat, "{0} @{1}: {2}", p.name, who.name, message);
DoFakePM(p, who, message); Player.Message(p, "[<] {0}: &f{1}", who.ColoredName, message);
} else if (who.Ignores.Names.CaselessContains(p.name)) {
DoFakePM(p, who, message);
} else {
DoPM(p, who, message);
}
if (!Chat.Ignoring(who, p)) {
Player.Message(who, "&9[>] {0}: &f{1}", p.ColoredName, message);
}
p.CheckForMessageSpam(); p.CheckForMessageSpam();
} }
@ -109,16 +108,5 @@ namespace MCGalaxy {
p.CheckForMessageSpam(); p.CheckForMessageSpam();
} }
static void DoFakePM(Player p, Player who, string message) {
Logger.Log(LogType.PrivateChat, "{0} @{1}: {2}", p.name, who.name, message);
Player.Message(p, "[<] {0}: &f{1}", who.ColoredName, message);
}
static void DoPM(Player p, Player who, string message) {
Logger.Log(LogType.PrivateChat, "{0} @{1}: {2}", p.name, who.name, message);
Player.Message(p, "[<] {0}: &f{1}", who.ColoredName, message);
Player.Message(who, "&9[>] {0}: &f{1}", p.ColoredName, message);
}
} }
} }

View File

@ -732,7 +732,7 @@ namespace MCGalaxy.Commands.CPE {
"Minimum coordinates for a normal block are &40 &20 &10." } }, "Minimum coordinates for a normal block are &40 &20 &10." } },
{ "max", new string[] { "Enter the three maximum coordinates of the cube in units (separated by spaces). 1 block = 16 units.", { "max", new string[] { "Enter the three maximum coordinates of the cube in units (separated by spaces). 1 block = 16 units.",
"Maximum coordinates for a normal block are &416 &216 &116." } }, "Maximum coordinates for a normal block are &416 &216 &116." } },
{ "collide", new string[] { "Type a number between '0' and '6' for collision type.", { "collide", new string[] { "Type a number between '0' and '7' for collision type.",
"0 - block is walk-through (e.g. air).", "1 - block is swim-through/climbable (e.g. rope).", "0 - block is walk-through (e.g. air).", "1 - block is swim-through/climbable (e.g. rope).",
"2 - block is solid (e.g. dirt).", "3 - block is solid, but slippery like ice", "2 - block is solid (e.g. dirt).", "3 - block is solid, but slippery like ice",
"4 - block is solid, but even slipperier than ice", "5 - block is swim-through like water", "4 - block is solid, but even slipperier than ice", "5 - block is swim-through like water",

View File

@ -44,8 +44,6 @@ namespace MCGalaxy {
old = new OldPerms(); old = new OldPerms();
if (PropertiesFile.Read(Paths.ServerPropsFile, ref old, LineProcessor)) if (PropertiesFile.Read(Paths.ServerPropsFile, ref old, LineProcessor))
Server.SettingsUpdate(); Server.SettingsUpdate();
if (old.saveZS)
ZSConfig.SaveSettings();
ZSConfig.LoadSettings(); ZSConfig.LoadSettings();
Database.Backend = ServerConfig.UseMySQL ? MySQLBackend.Instance : SQLiteBackend.Instance; Database.Backend = ServerConfig.UseMySQL ? MySQLBackend.Instance : SQLiteBackend.Instance;
@ -88,12 +86,7 @@ namespace MCGalaxy {
} }
if (!ConfigElement.Parse(Server.serverConfig, key, value, null)) { if (!ConfigElement.Parse(Server.serverConfig, key, value, null)) {
// Backwards compatibility: ZS used to be part of server.properties Logger.Log(LogType.Warning, "\"{0}\" was not a recognised server property key.", key);
if (ConfigElement.Parse(Server.zombieConfig, key, value, null)) {
perms.saveZS = true;
} else {
Logger.Log(LogType.Warning, "\"{0}\" was not a recognised server property key.", key);
}
} }
} }
@ -103,7 +96,6 @@ namespace MCGalaxy {
public int viewPerm = -1, nextPerm = -1, clearPerm = -1, opchatPerm = -1, adminchatPerm = -1; public int viewPerm = -1, nextPerm = -1, clearPerm = -1, opchatPerm = -1, adminchatPerm = -1;
public int mapGenLimit = -1, mapGenLimitAdmin = -1; public int mapGenLimit = -1, mapGenLimitAdmin = -1;
public int afkKickMins = -1; public LevelPermission afkKickMax = LevelPermission.Banned; public int afkKickMins = -1; public LevelPermission afkKickMax = LevelPermission.Banned;
public bool saveZS;
} }
internal static void FixupOldPerms() { internal static void FixupOldPerms() {

View File

@ -41,13 +41,11 @@ namespace MCGalaxy.Games {
return data; return data;
} }
bool needsSaveSettings;
public void LoadSettings() { public void LoadSettings() {
if (!File.Exists("properties/lavasurvival.properties")) { SaveSettings(); return; } if (!File.Exists("properties/lavasurvival.properties")) { SaveSettings(); return; }
try { try {
PropertiesFile.Read("properties/lavasurvival.properties", ProcessSettingsLine); PropertiesFile.Read("properties/lavasurvival.properties", ProcessSettingsLine);
if (needsSaveSettings) SaveSettings();
} catch (Exception e) { } catch (Exception e) {
Logger.LogError(e); Logger.LogError(e);
} }
@ -57,15 +55,6 @@ namespace MCGalaxy.Games {
switch (key.ToLower()) { switch (key.ToLower()) {
case "start-on-startup": StartOnStartup = bool.Parse(value); break; case "start-on-startup": StartOnStartup = bool.Parse(value); break;
case "lives": MaxLives = int.Parse(value); break; case "lives": MaxLives = int.Parse(value); break;
case "setup-rank":
LevelPermission setupRank = Group.ParsePermOrName(value, LevelPermission.Admin);
UpdateExtraPerms(setupRank, 1);
break;
case "control-rank":
LevelPermission controlRank = Group.ParsePermOrName(value, LevelPermission.Operator);
UpdateExtraPerms(controlRank, 2);
break;
case "maps": case "maps":
foreach (string name in value.Split(',')) { foreach (string name in value.Split(',')) {
string map = name.Trim(); string map = name.Trim();
@ -77,13 +66,6 @@ namespace MCGalaxy.Games {
} }
} }
void UpdateExtraPerms(LevelPermission perm, int num) {
CommandExtraPerms.Load();
CommandExtraPerms.Set("lavasurvival", perm, "temp desc", num);
CommandExtraPerms.Save();
needsSaveSettings = true;
}
public void SaveSettings() { public void SaveSettings() {
using (StreamWriter w = new StreamWriter("properties/lavasurvival.properties")) { using (StreamWriter w = new StreamWriter("properties/lavasurvival.properties")) {
w.WriteLine("#Lava Survival main properties"); w.WriteLine("#Lava Survival main properties");

View File

@ -32,8 +32,8 @@ namespace MCGalaxy {
internal Connection connection; internal Connection connection;
internal string[] channels, opchannels; internal string[] channels, opchannels;
internal string nick, server; internal string nick, server;
internal bool reset = false; internal bool resetting;
internal byte retries = 0; internal byte retries;
IRCHandlers handlers; IRCHandlers handlers;
ConnectionArgs args; ConnectionArgs args;
@ -78,7 +78,7 @@ namespace MCGalaxy {
/// <summary> Disconnects this bot from IRC, then reconnects to IRC if IRC is enabled. </summary> /// <summary> Disconnects this bot from IRC, then reconnects to IRC if IRC is enabled. </summary>
public void Reset() { public void Reset() {
reset = true; resetting = true;
retries = 0; retries = 0;
Disconnect("IRC Bot resetting..."); Disconnect("IRC Bot resetting...");
if (!ServerConfig.UseIRC) return; if (!ServerConfig.UseIRC) return;

View File

@ -125,27 +125,30 @@ namespace MCGalaxy.Network {
bot.Say("*" + p.DisplayName + " " + message, stealth); bot.Say("*" + p.DisplayName + " " + message, stealth);
} }
bool ToPublicChannel(ChatScope scope, object arg, ChatMessageFilter filter) { void MessageToIRC(ChatScope scope, string msg, object arg, ChatMessageFilter filter) {
return Chat.scopeFilters[(int)scope](ircGuest, arg) ChatMessageFilter scopeFilter = Chat.scopeFilters[(int)scope];
&& (filter == null || filter(ircGuest, arg));
if (scopeFilter(ircGuest, arg) && (filter == null || filter(ircGuest, arg))) {
bot.Say(msg, false);
} else {
// TODO: Check filters!!!!!
bot.Say(msg, true);
}
} }
void HandleChatSys(ChatScope scope, string msg, object arg, void HandleChatSys(ChatScope scope, string msg, object arg,
ref ChatMessageFilter filter, bool irc) { ref ChatMessageFilter filter, bool irc) {
if (!irc) return; if (irc) MessageToIRC(scope, msg, arg, filter);
bot.Say(msg, !ToPublicChannel(scope, arg, filter));
} }
void HandleChatFrom(ChatScope scope, Player source, string msg, void HandleChatFrom(ChatScope scope, Player source, string msg,
object arg, ref ChatMessageFilter filter, bool irc) { object arg, ref ChatMessageFilter filter, bool irc) {
if (!irc) return; if (irc) MessageToIRC(scope, Unescape(source, msg), arg, filter);
bot.Say(Unescape(source, msg), !ToPublicChannel(scope, arg, filter));
} }
void HandleChat(ChatScope scope, Player source, string msg, void HandleChat(ChatScope scope, Player source, string msg,
object arg, ref ChatMessageFilter filter, bool irc) { object arg, ref ChatMessageFilter filter, bool irc) {
if (!irc) return; if (irc) MessageToIRC(scope, Unescape(source, msg), arg, filter);
bot.Say(Unescape(source, msg), !ToPublicChannel(scope, arg, filter));
} }
void HandleShutdown(bool restarting, string message) { void HandleShutdown(bool restarting, string message) {
@ -344,7 +347,7 @@ namespace MCGalaxy.Network {
void Listener_OnRegistered() { void Listener_OnRegistered() {
Logger.Log(LogType.IRCCActivity, "Connected to IRC!"); Logger.Log(LogType.IRCCActivity, "Connected to IRC!");
bot.reset = false; bot.resetting = false;
bot.retries = 0; bot.retries = 0;
Authenticate(); Authenticate();
@ -378,7 +381,7 @@ namespace MCGalaxy.Network {
} }
void Listener_OnDisconnected() { void Listener_OnDisconnected() {
if (!bot.reset && bot.retries < 3) { bot.retries++; bot.Connect(); } if (!bot.resetting && bot.retries < 3) { bot.retries++; bot.Connect(); }
} }
void Listener_OnNick(UserInfo user, string newNick) { void Listener_OnNick(UserInfo user, string newNick) {

View File

@ -55,7 +55,7 @@ namespace MCGalaxy {
PlayerChat, PlayerChat,
/// <summary> Chat from IRC. </summary> /// <summary> Chat from IRC. </summary>
IRCChat, IRCChat,
/// <summary> Chat to all players in a particular chatroom, or across all chatrooms. </summary> /// <summary> Chat to all players in a particular chatroom, or across all chatrooms. </summary>
ChatroomChat, ChatroomChat,

View File

@ -54,7 +54,7 @@ namespace MCGalaxy {
public static INetworkListen Listener; public static INetworkListen Listener;
//Other //Other
public static bool ServerSetupFinished = false; public static bool SetupFinished = false;
public static CTFGame ctf = new CTFGame(); public static CTFGame ctf = new CTFGame();
public static PlayerList bannedIP, whiteList, ircControllers, invalidIds; public static PlayerList bannedIP, whiteList, ircControllers, invalidIds;

View File

@ -62,7 +62,7 @@ namespace MCGalaxy {
hidden = PlayerList.Load("ranks/hidden.txt"); hidden = PlayerList.Load("ranks/hidden.txt");
vip = PlayerList.Load("text/vip.txt"); vip = PlayerList.Load("text/vip.txt");
noEmotes = PlayerList.Load("text/emotelist.txt"); noEmotes = PlayerList.Load("text/emotelist.txt");
lockdown = PlayerList.Load("text/lockdown.txt"); lockdown = PlayerList.Load("text/lockdown.txt");
models = PlayerExtList.Load("extra/models.txt"); models = PlayerExtList.Load("extra/models.txt");
skins = PlayerExtList.Load("extra/skins.txt"); skins = PlayerExtList.Load("extra/skins.txt");
reach = PlayerExtList.Load("extra/reach.txt"); reach = PlayerExtList.Load("extra/reach.txt");
@ -71,9 +71,9 @@ namespace MCGalaxy {
modelScales = PlayerExtList.Load("extra/modelscales.txt"); modelScales = PlayerExtList.Load("extra/modelscales.txt");
muted = PlayerExtList.Load("ranks/muted.txt"); muted = PlayerExtList.Load("ranks/muted.txt");
frozen = PlayerExtList.Load("ranks/frozen.txt"); frozen = PlayerExtList.Load("ranks/frozen.txt");
tempRanks = PlayerExtList.Load(Paths.TempRanksFile); tempRanks = PlayerExtList.Load(Paths.TempRanksFile);
tempBans = PlayerExtList.Load(Paths.TempBansFile); tempBans = PlayerExtList.Load(Paths.TempBansFile);
ModerationTasks.QueueTasks(); ModerationTasks.QueueTasks();
if (ServerConfig.WhitelistedOnly) if (ServerConfig.WhitelistedOnly)
@ -129,7 +129,7 @@ namespace MCGalaxy {
TimeSpan.FromMilliseconds(20)); TimeSpan.FromMilliseconds(20));
Logger.Log(LogType.SystemActivity, "Finished setting up server, finding classicube.net url.."); Logger.Log(LogType.SystemActivity, "Finished setting up server, finding classicube.net url..");
ServerSetupFinished = true; SetupFinished = true;
} }
static void InitZombieSurvival() { static void InitZombieSurvival() {

View File

@ -268,7 +268,7 @@ namespace MCGalaxy {
lvl.SaveBlockDBChanges(); lvl.SaveBlockDBChanges();
} }
if (Server.ServerSetupFinished && !ServerConfig.AutoLoadMaps) { if (Server.SetupFinished && !ServerConfig.AutoLoadMaps) {
File.WriteAllText("text/autoload.txt", autoload); File.WriteAllText("text/autoload.txt", autoload);
} }
} catch (Exception ex) { Logger.LogError(ex); } } catch (Exception ex) { Logger.LogError(ex); }