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