static void Save(Player p, Level lvl, string backup) { if (!TrySave(p, lvl, true)) { return; } p.Message("Level {0} &Ssaved", lvl.ColoredName); LevelOperations.Backup(p, lvl, backup); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { LevelOperations.OutputBackups(p, p.level); return; } Level lvl; string[] args = message.SplitSpaces(); if (args.Length >= 2) { lvl = Matcher.FindLevels(p, args[1]); if (lvl == null) { return; } } else { if (p.IsSuper) { SuperRequiresArgs(p, "level name"); return; } lvl = p.level; } if (!LevelInfo.Check(p, data.Rank, lvl, "restore a backup of this level")) { return; } string path = LevelInfo.BackupFilePath(lvl.name, args[0]); if (File.Exists(path)) { DoRestore(lvl, args[0]); } else { p.Message("Backup {0} does not exist.", args[0]); LevelOperations.OutputBackups(p, lvl); } }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } if (!Formatter.ValidMapName(p, message)) { return; } string path = LevelInfo.BackupFilePath(p.level.name, message); if (File.Exists(path)) { p.Message("Select two corners for restore."); p.MakeSelection(2, "Selecting region for &SRestore", path, DoRestore); } else { p.Message("Backup {0} does not exist.", message); LevelOperations.OutputBackups(p, p.level); } }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { LevelOperations.OutputBackups(p, p.level); return; } string[] args = message.ToLower().SplitSpaces(); string mapArg = args.Length > 1 ? args[0] : p.level.MapName; string backupArg = args.Length > 1 ? args[1] : args[0]; string path; if (backupArg == currentFlag) { path = LevelInfo.MapPath(mapArg); if (!LevelInfo.MapExists(mapArg)) { if (Directory.Exists(LevelInfo.BackupBasePath(mapArg))) { p.Message("&WLevel \"{0}\" does not currently exist, &Showever:", mapArg); LevelOperations.OutputBackups(p, mapArg, LevelInfo.GetConfig(mapArg)); } else { p.Message("&WLevel \"{0}\" does not exist and no backups could be found.", mapArg); } return; } } else { if (!Directory.Exists(LevelInfo.BackupBasePath(mapArg))) { p.Message("Level \"{0}\" has no backups.", mapArg); return; } if (backupArg == latestFlag) { int latest = LevelInfo.LatestBackup(mapArg); if (latest == 0) { p.Message("&WLevel \"{0}\" does not have any numbered backups, " + "so the latest backup could not be determined.", mapArg); return; } backupArg = latest.ToString(); } path = LevelInfo.BackupFilePath(mapArg, backupArg); } if (!File.Exists(path)) { p.Message("Backup \"{0}\" for {1} could not be found.", backupArg, mapArg); return; } string formattedMuseumName; if (backupArg == currentFlag) { formattedMuseumName = "&cMuseum &S(" + mapArg + ")"; } else { formattedMuseumName = "&cMuseum &S(" + mapArg + " " + backupArg + ")"; } if (p.level.name.CaselessEq(formattedMuseumName)) { p.Message("You are already in this museum."); return; } if (Interlocked.CompareExchange(ref p.LoadingMuseum, 1, 0) == 1) { p.Message("You are already loading a museum level."); return; } try { Level lvl = LevelActions.LoadMuseum(p, formattedMuseumName, mapArg, path); PlayerActions.ChangeMap(p, lvl); } finally { Interlocked.Exchange(ref p.LoadingMuseum, 0); } }