Skip to content

Commit

Permalink
Configurable delay before loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cerus committed Mar 2, 2022
1 parent a373d5f commit 2f0d38e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugin/src/main/java/dev/cerus/maps/plugin/MapsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
import dev.cerus.maps.plugin.command.MapsCommand;
import dev.cerus.maps.plugin.map.MapScreenRegistry;
import dev.cerus.maps.version.VersionAdapterFactory;
import java.io.File;
import java.util.logging.Logger;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

public class MapsPlugin extends JavaPlugin {

@Override
public void onEnable() {
this.saveResource("maps_config.yml", false);
final YamlConfiguration mapsConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "maps_config.yml"));

final VersionAdapter versionAdapter = new VersionAdapterFactory().makeAdapter();
if (versionAdapter == null) {
final Logger logger = this.getLogger();
Expand All @@ -29,9 +34,11 @@ public void onEnable() {
this.getServer().getScheduler().runTaskLater(this, () -> {
final FileConfiguration config = this.getConfig();
if (config.contains("screens")) {
this.getLogger().info("Loading screens..");
MapScreenRegistry.load(config, versionAdapter);
this.getLogger().info(MapScreenRegistry.getScreenIds().size() + " screens were loaded");
}
}, 3 * 20);
}, mapsConfig.getInt("loading-delay", 3) * 20L);

final BukkitCommandManager commandManager = new BukkitCommandManager(this);
commandManager.registerDependency(VersionAdapter.class, versionAdapter);
Expand Down
1 change: 1 addition & 0 deletions plugin/src/main/resources/maps_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loading-delay: 3

0 comments on commit 2f0d38e

Please sign in to comment.