mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-31 22:41: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)
|
# Ob der Spieler sich übertrinken kann und dann in Ohnmacht fällt (gekickt wird)
|
||||||
enableKickOnOverdrink: true
|
enableKickOnOverdrink: true
|
||||||
|
|
||||||
|
# Autosave Intervall in Minuten
|
||||||
|
autosave: 3
|
||||||
|
|
||||||
|
|
||||||
# name: versch. Namen für schlecht/mittel/gut
|
# name: versch. Namen für schlecht/mittel/gut
|
||||||
# ingredients: Auflistung von material/Anzahl
|
# ingredients: Auflistung von material/Anzahl
|
||||||
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
# 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 class P extends JavaPlugin {
|
||||||
public static P p;
|
public static P p;
|
||||||
public static int lastBackup = 0;
|
public static int lastBackup = 0;
|
||||||
|
public static int lastSave = 1;
|
||||||
|
public static int autosave = 3;
|
||||||
|
|
||||||
// Listeners
|
// Listeners
|
||||||
public BlockListener blockListener;
|
public BlockListener blockListener;
|
||||||
@ -94,6 +96,9 @@ public class P extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
|
|
||||||
|
// various Settings
|
||||||
|
autosave = config.getInt("autosave", 3);
|
||||||
|
|
||||||
// loading recipes
|
// loading recipes
|
||||||
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
ConfigurationSection configSection = config.getConfigurationSection("recipes");
|
||||||
if (configSection != null) {
|
if (configSection != null) {
|
||||||
@ -250,6 +255,7 @@ public class P extends JavaPlugin {
|
|||||||
|
|
||||||
// save all Data
|
// save all Data
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
|
log("saving");
|
||||||
File datafile = new File(p.getDataFolder(), "data.yml");
|
File datafile = new File(p.getDataFolder(), "data.yml");
|
||||||
|
|
||||||
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
FileConfiguration oldData = YamlConfiguration.loadConfiguration(datafile);
|
||||||
@ -285,6 +291,8 @@ public class P extends JavaPlugin {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastSave = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int parseInt(String string) {
|
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
|
Barrel.onUpdate();// runs every min to check and update ageing time
|
||||||
BPlayer.onUpdate();// updates players drunkeness
|
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