示例#1
0
		/// <summary>
		/// SaveWorld event handler which notifies users that the server may lag
		/// </summary>
		public void OnSaveWorld(WorldSaveEventArgs args)
		{
			if (TShock.Config.AnnounceSave)
			{
				// Protect against internal errors causing save failures
				// These can be caused by an unexpected error such as a bad or out of date plugin
				try
				{
					TShock.Utils.Broadcast("Saving world. Momentary lag might result from this.", Color.Red);
				}
				catch (Exception ex)
				{
					TShock.Log.Error("World saved notification failed");
					TShock.Log.Error(ex.ToString());
				}
			}
		}
    private void World_SaveWorld(WorldSaveEventArgs e) {
      if (this.isDisposed || !this.hooksEnabled || e.Handled)
        return;

      try {
        this.WorldMetadataHandler.WriteMetadata();
      } catch (Exception ex) {
        this.Trace.WriteLineError("A Save World Handler has thrown an exception:\n{0}", ex.ToString());
      }
    }
示例#3
0
		internal bool InvokeWorldSave(bool resetTime)
		{
			WorldSaveEventArgs args = new WorldSaveEventArgs
			{
				ResetTime = resetTime
			};

			this.WorldSave.Invoke(args);
			return args.Handled;
		}
示例#4
0
 void OnSaveWorld(WorldSaveEventArgs e)
 {
     new SaveCommand(Actions.ToArray()).Execute();
     Actions.Clear();
 }
        private void World_SaveWorld(WorldSaveEventArgs e)
        {
            if (this.isDisposed || !this.hooksEnabled || e.Handled)
            return;

              try {
            lock (this.WorldMetadataHandler.Metadata.Protections) {
              Stopwatch watch = new Stopwatch();
              watch.Start();
              this.WorldMetadataHandler.WriteMetadata();
              Console.WriteLine(File.GetLastWriteTime(Main.worldPathName));
              watch.Stop();

              string format = "Serializing the protection data took {0}ms.";
              if (watch.ElapsedMilliseconds == 0)
            format = "Serializing the protection data took less than 1ms.";

              this.Trace.WriteLineInfo(format, watch.ElapsedMilliseconds);
            }
              } catch (Exception ex) {
            this.Trace.WriteLineError("Unhandled exception in SaveWorld handler:\n" + ex);
              }
        }
示例#6
0
        public void onSave(WorldSaveEventArgs e)
        {
            TSPlayer.All.SendMessage("[cClass] Saving player statistics.. Possible lags!", Color.Silver);
            string path = Path.Combine(TShock.SavePath, "cClassData1_4.json");
            Config.blockedNPCs = Variables.blockedNPCs;

            Config.Write(path);
            TSPlayer.All.SendMessage("[cClass] Saved statistics!", Color.Silver);
        }
示例#7
0
 /// <summary>
 /// WorldSave callback.
 /// </summary>
 /// <param name="args"></param>
 private void OnWorldSave(WorldSaveEventArgs args)
 {
     lock (this.m_AddonsLock)
     {
         this.m_Addons.ForEach(a =>
             {
                 var ret = a.Value.InvokeEvent("WorldSave", args);
                 if (ret != null && ret.Length >= 1)
                 {
                     bool result;
                     if (bool.TryParse(ret[0].ToString(), out result) && result)
                         args.Handled = true;
                 }
             });
     }
 }
示例#8
0
        public static void OnWorldSave(WorldSaveEventArgs args)
        {
            try
            {
                if (TShock.Config.AnnounceSave)
                    TShock.Utils.Broadcast(VocationPlugin.Resources.INFO_SAVING, Color.Red);

                Config.Write();
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(VocationPlugin.Resources.ERR_SAVING);
                Console.ForegroundColor = ConsoleColor.Gray;
                TShock.Log.Error(VocationPlugin.Resources.ERR_SAVING);
                TShock.Log.Error(e.ToString());
            }
        }