public static int rollback(final String playerName) { final List<RollbackEntry> entries = getEntriesByPlayer(playerName); if (entries == null) { return 0; } int count = entries.size(); for (RollbackEntry entry : entries) { if (entry != null) { entry.restore(); } } if (!REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase())) { REMOVE_ROLLBACK_HISTORY.add(playerName.toLowerCase()); } new BukkitRunnable() { @Override public void run() { if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase())) { REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase()); purgeEntries(playerName); } } }.runTaskLater(TotalFreedomMod.plugin, 40L * 20L); return count; }
public static int undoRollback(String playerName) { final List<RollbackEntry> entries = getEntriesByPlayer(playerName); if (entries == null) { return 0; } final int count = entries.size(); final ListIterator<RollbackEntry> it = entries.listIterator(count); while (it.hasPrevious()) { RollbackEntry entry = it.previous(); if (entry != null) { entry.redo(); } } if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase())) { REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase()); } return count; }