mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-20 20:51:20 +01:00
Autosave Interval
This commit is contained in:
parent
edf8c7a840
commit
ae3df4eb8f
@ -21,6 +21,10 @@ enableLoginDisallow: true
|
||||
# Ob der Spieler sich übertrinken kann und dann in Ohnmacht fällt (gekickt wird)
|
||||
enableKickOnOverdrink: true
|
||||
|
||||
# Autosave Intervall in Minuten
|
||||
autosave: 3
|
||||
|
||||
|
||||
# name: versch. Namen für schlecht/mittel/gut
|
||||
# ingredients: Auflistung von material/Anzahl
|
||||
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
||||
|
@ -27,6 +27,8 @@ import org.bukkit.block.Block;
|
||||
public class P extends JavaPlugin {
|
||||
public static P p;
|
||||
public static int lastBackup = 0;
|
||||
public static int lastSave = 1;
|
||||
public static int autosave = 3;
|
||||
|
||||
// Listeners
|
||||
public BlockListener blockListener;
|
||||
@ -94,6 +96,9 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
FileConfiguration config = getConfig();
|
||||
|
||||
// various Settings
|
||||
autosave = config.getInt("autosave", 3);
|
||||
|
||||
// loading recipes
|
||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||
if (configSection != null) {
|
||||
@ -250,6 +255,7 @@ public class P extends JavaPlugin {
|
||||
|
||||
// save all Data
|
||||
public void saveData() {
|
||||
log("saving");
|
||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||
|
||||
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
||||
@ -285,6 +291,8 @@ public class P extends JavaPlugin {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
lastSave = 1;
|
||||
}
|
||||
|
||||
public int parseInt(String string) {
|
||||
@ -319,7 +327,11 @@ public class P extends JavaPlugin {
|
||||
Barrel.onUpdate();// runs every min to check and update ageing time
|
||||
BPlayer.onUpdate();// updates players drunkeness
|
||||
|
||||
saveData();// save all data
|
||||
if (lastSave >= autosave) {
|
||||
saveData();// save all data
|
||||
} else {
|
||||
lastSave++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user