add a config option to disable backups. closes #45
This commit is contained in:
@@ -55,6 +55,7 @@ public class PlayerVaults extends JavaPlugin {
|
||||
private boolean saveQueued;
|
||||
private String name = "";
|
||||
private File configFile;
|
||||
private boolean backupsEnabled;
|
||||
private File backupsFolder = null;
|
||||
private File vaultData;
|
||||
|
||||
@@ -68,6 +69,7 @@ public class PlayerVaults extends JavaPlugin {
|
||||
new UUIDVaultManager();
|
||||
getServer().getPluginManager().registerEvents(new Listeners(this), this);
|
||||
loadConfig();
|
||||
this.backupsEnabled = this.getConfig().getBoolean("backups.enabled", true);
|
||||
loadSigns();
|
||||
checkUpdate();
|
||||
getCommand("pv").setExecutor(new VaultCommand());
|
||||
@@ -214,6 +216,7 @@ public class PlayerVaults extends JavaPlugin {
|
||||
int ecoDelete = getConfig().getInt("economy.refund-on-delete", 50);
|
||||
boolean dropEnabled = getConfig().getBoolean("drop-on-death.enabled", false);
|
||||
int dropInvs = getConfig().getInt("drop-on-death.inventories", 50);
|
||||
boolean backupsEnabled = getConfig().getBoolean("backups.enabled", true);
|
||||
configFile.delete();
|
||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(getResource("config.yml"));
|
||||
setInConfig("check-update", checkUpdate, conf);
|
||||
@@ -223,6 +226,7 @@ public class PlayerVaults extends JavaPlugin {
|
||||
setInConfig("economy.refund-on-delete", ecoDelete, conf);
|
||||
setInConfig("drop-on-death.enabled", dropEnabled, conf);
|
||||
setInConfig("drop-on-death.inventories", dropInvs, conf);
|
||||
setInConfig("backups.enabled", backupsEnabled, conf);
|
||||
try {
|
||||
conf.save(configFile);
|
||||
} catch (IOException e) {
|
||||
@@ -338,6 +342,10 @@ public class PlayerVaults extends JavaPlugin {
|
||||
return this.vaultData;
|
||||
}
|
||||
|
||||
public boolean isBackupsEnabled() {
|
||||
return this.backupsEnabled;
|
||||
}
|
||||
|
||||
public File getBackupsFolder() {
|
||||
// having this in #onEnable() creates the 'uuidvaults' directory, preventing the conversion from running
|
||||
if (this.backupsFolder == null) {
|
||||
|
||||
@@ -239,7 +239,7 @@ public class UUIDVaultManager {
|
||||
*/
|
||||
public void saveFile(UUID holder, YamlConfiguration yaml) throws IOException {
|
||||
File file = new File(directory, holder.toString() + ".yml");
|
||||
if (file.exists()) {
|
||||
if (file.exists() && PlayerVaults.getInstance().isBackupsEnabled()) {
|
||||
file.renameTo(new File(PlayerVaults.getInstance().getBackupsFolder(), holder.toString() + ".yml"));
|
||||
}
|
||||
yaml.save(file);
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.List;
|
||||
/**
|
||||
* A class for managing actual IO to the files, loading inventories, and saving them.
|
||||
*/
|
||||
@Deprecated
|
||||
public class VaultManager {
|
||||
|
||||
public PlayerVaults plugin;
|
||||
@@ -260,7 +261,7 @@ public class VaultManager {
|
||||
@Deprecated
|
||||
public void saveFile(String holder, YamlConfiguration yaml) throws IOException {
|
||||
File file = new File(directory + File.separator + holder.toLowerCase() + ".yml");
|
||||
if (file.exists()) {
|
||||
if (file.exists() && PlayerVaults.getInstance().isBackupsEnabled()) {
|
||||
file.renameTo(new File(PlayerVaults.getInstance().getBackupsFolder(), holder.toLowerCase() + ".yml"));
|
||||
}
|
||||
yaml.save(file);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# PlayerVaults by drsthock and gomeow!
|
||||
# PlayerVaults by https://github.com/drtshock/PlayerVaults/graphs/contributors
|
||||
# http://dev.bukkit.org/bukkit-plugins/playervaults/
|
||||
# Made with love :3
|
||||
|
||||
@@ -30,3 +30,7 @@ cleanup:
|
||||
# If a file hasn't been edited for this long, we'll clean it up.
|
||||
# Time is in days.
|
||||
lastEdit: 30
|
||||
|
||||
backups:
|
||||
# If you don't want any backups created change this to false.
|
||||
enabled: true
|
||||
|
||||
Reference in New Issue
Block a user