diff --git a/MCGalaxy/Events/LevelEvents.cs b/MCGalaxy/Events/LevelEvents.cs index eba6d2ef8..184dcaf54 100644 --- a/MCGalaxy/Events/LevelEvents.cs +++ b/MCGalaxy/Events/LevelEvents.cs @@ -99,5 +99,32 @@ namespace MCGalaxy.Events.LevelEvents { if (handlers.Count == 0) return; CallCommon(pl => pl(x, y, z, extraInfo, l)); } - } + } + + public delegate void OnLevelRenamed(string srcMap, string dstMap); + public sealed class OnLevelRenamedEvent : IEvent { + + public static void Call(string srcMap, string dstMap) { + if (handlers.Count == 0) return; + CallCommon(pl => pl(srcMap, dstMap)); + } + } + + public delegate void OnLevelCopied(string srcMap, string dstMap); + public sealed class OnLevelCopiedEvent : IEvent { + + public static void Call(string srcMap, string dstMap) { + if (handlers.Count == 0) return; + CallCommon(pl => pl(srcMap, dstMap)); + } + } + + public delegate void OnLevelDeleted(string map); + public sealed class OnLevelDeletedEvent : IEvent { + + public static void Call(string map) { + if (handlers.Count == 0) return; + CallCommon(pl => pl(map)); + } + } } diff --git a/MCGalaxy/Levels/LevelActions.cs b/MCGalaxy/Levels/LevelActions.cs index 29900a5ec..9d00ad33b 100644 --- a/MCGalaxy/Levels/LevelActions.cs +++ b/MCGalaxy/Levels/LevelActions.cs @@ -81,6 +81,7 @@ namespace MCGalaxy { RenameDatabaseTables(p, src, dst); BlockDBFile.MoveBackingFile(src, dst); + OnLevelRenamedEvent.Call(src, dst); if (players == null) return true; // Move all the old players to the renamed map @@ -173,6 +174,7 @@ namespace MCGalaxy { DoAll(map, "", action_delete); DeleteDatabaseTables(map); BlockDBFile.DeleteBackingFile(map); + OnLevelDeletedEvent.Call(map); return true; } @@ -234,6 +236,7 @@ namespace MCGalaxy { File.Copy(LevelInfo.MapPath(src), LevelInfo.MapPath(dst)); DoAll(src, dst, action_copy); CopyDatabaseTables(src, dst); + OnLevelCopiedEvent.Call(src, dst); return true; }