mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 01:45:44 -05:00
Re-introduce autosave enabler
This commit is contained in:
parent
b5e1aa0ac0
commit
b2936da79e
2 changed files with 18 additions and 0 deletions
|
@ -80,6 +80,8 @@ public final class Main extends JavaPlugin {
|
|||
this.getServer().getPluginManager().registerEvents(new PlayerPrefix(), this);
|
||||
|
||||
/* Server-related modules */
|
||||
ServerGameRule.init(this);
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(new ServerCommand(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ServerGameRule(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new ServerTabComplete(), this);
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package pw.kaboom.extras.modules.server;
|
||||
|
||||
import io.papermc.paper.event.world.WorldGameRuleChangeEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
public final class ServerGameRule implements Listener {
|
||||
@EventHandler
|
||||
|
@ -19,4 +23,16 @@ public final class ServerGameRule implements Listener {
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void enableAutoSave() {
|
||||
for (final World world: Bukkit.getWorlds()) {
|
||||
world.setAutoSave(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(final Main main) {
|
||||
final BukkitScheduler scheduler = Bukkit.getScheduler();
|
||||
|
||||
scheduler.runTaskTimer(main, ServerGameRule::enableAutoSave, 0L, 600L); // 30 seconds
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue