Skip to content

Commit

Permalink
Fixed a bug where the wrong backups where being deleted in rollback c…
Browse files Browse the repository at this point in the history
…ommand
  • Loading branch information
MehradN committed Mar 5, 2023
1 parent 1779801 commit 18e23b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static int deleteBackup(CommandContext<ServerCommandSource> context, int
switch (position) {
case 0 -> index = 0;
case -1 -> index = -1;
default -> index = IntegerArgumentType.getInteger(context, "number") - 1;
default -> index = -IntegerArgumentType.getInteger(context, "number");
}

boolean f = backupManager.deleteBackup(worldName, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ public boolean createRollbackBackup(MinecraftServer server) {
public boolean deleteBackup(String worldName, int index) {
Rollback.LOGGER.info("Deleting the backup #{}...", index);
JsonArray array = getWorldObject(worldName).getAsJsonArray("backups");

if (array.size() <= index || index < -array.size())
return true;
if (index < 0)
index += array.size();
if (index >= array.size())
return true;

RollbackBackup backup = new RollbackBackup(worldName, array.get(index).getAsJsonObject());

Expand Down

0 comments on commit 18e23b5

Please sign in to comment.