summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2011-10-16 08:58:45 +0100
committerElgarL <ElgarL@palmergames.com>2011-10-16 08:58:45 +0100
commit2951cca5599e166d8940b94bd9dc5bdec01c706c (patch)
tree00c6ffa81d5da651448499c89bca5ae327be145b /EssentialsGroupManager
parentfff6601237534530905417d7548a88690e17a23a (diff)
downloadEssentials-2951cca5599e166d8940b94bd9dc5bdec01c706c.tar
Essentials-2951cca5599e166d8940b94bd9dc5bdec01c706c.tar.gz
Essentials-2951cca5599e166d8940b94bd9dc5bdec01c706c.tar.lz
Essentials-2951cca5599e166d8940b94bd9dc5bdec01c706c.tar.xz
Essentials-2951cca5599e166d8940b94bd9dc5bdec01c706c.zip
Added data.save.hours setting to config. This allow control over how
long backups are retained.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt3
-rw-r--r--EssentialsGroupManager/src/config.yml2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java1
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java6
6 files changed, 14 insertions, 4 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 4f4851f0a..6729907b5 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -47,4 +47,5 @@ v 1.4:
- Added a config setting - bukkit_perms_override: false
Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
- Fixed reading world mirrors from the config.
- - Simplified config.yml while retaining backwards compatibility. \ No newline at end of file
+ - Simplified config.yml while retaining backwards compatibility.
+ - Added data.save.hours setting to config. This allow control over how long backups are retained. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index caa675527..25fb5dcd0 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -11,6 +11,8 @@ settings:
save:
# How often GroupManager will save it's data back to groups and users.yml
minutes: 10
+ # Number of hours to retain backups (plugins/GroupManager/backup)
+ hours: 24
logging:
# level of detail GroupManager will use when logging.
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index 302f12b67..ad2945076 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -70,6 +70,10 @@ public class GMConfiguration {
public Integer getSaveInterval() {
return GMconfig.getInt("settings.data.save.minutes", 10);
}
+
+ public Integer getBackupDuration() {
+ return GMconfig.getInt("settings.data.save.hours", 24);
+ }
public void adjustLoggerLevel() {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index 1f55f73ad..5ef4fc537 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -163,6 +163,7 @@ public class GroupManager extends JavaPlugin {
int minutes = getGMConfig().getSaveInterval();
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
+ GroupManager.logger.info("Backups will be retained for " + getGMConfig().getBackupDuration() + " hours!");
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 573fcebc3..7cbe4f65c 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -168,7 +168,7 @@ public class WorldsHolder {
if (alreadyDone.contains(w)) {
continue;
}
- Tasks.removeOldFiles(plugin.getBackupFolder());
+ Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
if (w == null) {
GroupManager.logger.severe("WHAT HAPPENED?");
continue;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
index 8e4d58dde..f3defd94a 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java
@@ -13,6 +13,8 @@ import java.io.OutputStream;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
+
+import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
/**
@@ -43,9 +45,9 @@ public abstract class Tasks {
copy(in, dst);
}
- public static void removeOldFiles(File folder) {
+ public static void removeOldFiles(GroupManager gm, File folder) {
if (folder.isDirectory()) {
- long oldTime = System.currentTimeMillis() - 86400000L;
+ long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000);
for (File olds : folder.listFiles()) {
if (olds.isFile()) {
if (olds.lastModified() < oldTime) {