EmperorJoo

Untitled

Mar 19th, 2026
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading;
  4. using ConquerServer.Network;
  5.  
  6. namespace ConquerServer.Features
  7. {
  8. public class FloorCleaner
  9. {
  10. private const int CleanIntervalSeconds = 300;
  11. private static Timer _cleanTimer;
  12.  
  13. /// <summary>
  14. /// Timer ⌛ Conquer Lab Page
  15. /// </summary>
  16. public static void Initialize()
  17. {
  18. _cleanTimer = new Timer(CleanFloor, null, CleanIntervalSeconds * 1000, CleanIntervalSeconds * 1000);
  19. Console.WriteLine("[System]: Auto Floor Cleaner initialized.");
  20. }
  21.  
  22.  
  23. private static void CleanFloor(object state)
  24. {
  25. int itemsRemoved = 0;
  26.  
  27. // All (Maps)
  28. foreach (var map in Kernel.Maps.Values)
  29. {
  30.  
  31. foreach (var item in map.FloorItems.Values.ToList())
  32. {
  33.  
  34. if (map.RemoveFloorItem(item))
  35. {
  36. itemsRemoved++;
  37. }
  38. }
  39. }
  40.  
  41. // (Global Message) Players
  42. if (itemsRemoved > 0)
  43. {
  44. Kernel.SendGlobalMessage($"[System]: {itemsRemoved} items cleaned from the floor to reduce lag.", MsgTalk.Channel.Service, MsgTalk.Color.Red);
  45. Console.WriteLine($"[System]: Floor cleaned. Removed {itemsRemoved} items.");
  46. }
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment