Some more javadoc
This commit is contained in:
@@ -4,25 +4,42 @@ import fr.pandacube.lib.bungee.util.BungeeDailyLogRotateFileHandler;
|
||||
import fr.pandacube.lib.bungee.util.PluginMessagePassthrough;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* General class used to initialize some tools of pandalib-bungee, following the bungee plugin's lifecycle.
|
||||
*/
|
||||
public class PandaLibBungee {
|
||||
|
||||
private static Plugin plugin;
|
||||
|
||||
/**
|
||||
* Method to be called in {@link Plugin#onLoad()} method.
|
||||
* @param plugin the plugin instance.
|
||||
*/
|
||||
public static void onLoad(Plugin plugin) {
|
||||
PandaLibBungee.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called in {@link Plugin#onEnable()} method.
|
||||
*/
|
||||
public static void onEnable() {
|
||||
PluginMessagePassthrough.init(plugin);
|
||||
BungeeDailyLogRotateFileHandler.init(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to be called in {@link Plugin#onDisable()} method.
|
||||
*/
|
||||
public static void disable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin instance.
|
||||
* @return the plugin instance.
|
||||
*/
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
@@ -6,12 +6,33 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class that holds the configuration varables for {@link BungeeBackupManager}.
|
||||
*/
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class BungeeBackupConfig {
|
||||
/**
|
||||
* Tells if the working directory of the current bungee instance should be backed up.
|
||||
*/
|
||||
public boolean workdirBackupEnabled = true;
|
||||
/**
|
||||
* Tells if the old logs of the current bungee instance should be backed up.
|
||||
*/
|
||||
public boolean logsBackupEnabled = true;
|
||||
/**
|
||||
* The cron scheduling of when the workdir backup occurs.
|
||||
*/
|
||||
public String scheduling = "0 2 * * *"; // cron format, here is every day at 2am
|
||||
/**
|
||||
* The destination directory for the backups.
|
||||
*/
|
||||
public File backupDirectory = null;
|
||||
/**
|
||||
* The configuration handling the cleaning of the backup directory.
|
||||
*/
|
||||
public BackupCleaner workdirBackupCleaner = BackupCleaner.KEEPING_1_EVERY_N_MONTH(3).merge(BackupCleaner.KEEPING_N_LAST(5));
|
||||
/**
|
||||
* A list of ignored files or directory in the workdir to exclude from the backup.
|
||||
*/
|
||||
public List<String> workdirIgnoreList = new ArrayList<>();
|
||||
}
|
||||
|
@@ -6,10 +6,17 @@ import fr.pandacube.lib.core.backup.RotatedLogsBackupProcess;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Handles the backup processes for a Bungeecord instance.
|
||||
*/
|
||||
public class BungeeBackupManager extends BackupManager {
|
||||
|
||||
BungeeBackupConfig config;
|
||||
|
||||
|
||||
/**
|
||||
* Instanciate a new {@link BungeeBackupManager}.
|
||||
* @param config the configuration.
|
||||
*/
|
||||
public BungeeBackupManager(BungeeBackupConfig config) {
|
||||
super(config.backupDirectory);
|
||||
setConfig(config);
|
||||
@@ -24,12 +31,19 @@ public class BungeeBackupManager extends BackupManager {
|
||||
super.addProcess(process);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new configuration for this backup manager.
|
||||
* @param config the new configuration.
|
||||
*/
|
||||
public void setConfig(BungeeBackupConfig config) {
|
||||
this.config = config;
|
||||
backupQueue.forEach(this::updateProcessConfig);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deploys the new configuration to the provided backup process.
|
||||
* @param process the process on which to apply the new config.
|
||||
*/
|
||||
public void updateProcessConfig(BackupProcess process) {
|
||||
if (process instanceof BungeeWorkdirProcess) {
|
||||
process.setEnabled(config.workdirBackupEnabled);
|
||||
|
@@ -5,8 +5,15 @@ import fr.pandacube.lib.core.backup.BackupProcess;
|
||||
import java.io.File;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
/**
|
||||
* The backup process responsible for the working directory of the current Bungeecord instance.
|
||||
*/
|
||||
public class BungeeWorkdirProcess extends BackupProcess {
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates this backup process.
|
||||
* @param bm the backup manager.
|
||||
*/
|
||||
protected BungeeWorkdirProcess(BungeeBackupManager bm) {
|
||||
super(bm, "workdir");
|
||||
}
|
||||
|
Reference in New Issue
Block a user