Skip to content

Commit

Permalink
Code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmq committed Apr 2, 2024
1 parent 03a66c6 commit 9cdafab
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main/java/dev/magicmq/pyspigot/PySpigot.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public class PySpigot extends JavaPlugin {

private FileConfiguration scriptOptionsConfig;
private Metrics metrics;

private BukkitTask versionCheckTask;
private volatile String spigotVersion;

Expand All @@ -100,19 +99,6 @@ public void onEnable() {
initFolders();
initHelperLibs();

fetchSpigotVersion();
Bukkit.getScheduler().runTaskLater(this, () -> {
if (spigotVersion != null && !PluginConfig.shouldSuppressUpdateMessages()) {
StringUtils.Version currentVersion = new StringUtils.Version(getDescription().getVersion());
StringUtils.Version latestVersion = new StringUtils.Version(spigotVersion);
if (currentVersion.compareTo(latestVersion) < 0) {
getLogger().log(Level.WARNING, "You're running an outdated version of PySpigot. The latest version is " + spigotVersion + ".");
getLogger().log(Level.WARNING, "Download it here: https://www.spigotmc.org/resources/pyspigot.111006/");
}
}
}, 20L);
versionCheckTask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::fetchSpigotVersion, 864000L, 864000L);

getConfig().options().copyDefaults(true);
saveDefaultConfig();
reloadConfig();
Expand Down Expand Up @@ -146,6 +132,19 @@ public void onEnable() {

if (PluginConfig.getMetricsEnabled())
setupMetrics();

fetchSpigotVersion();
Bukkit.getScheduler().runTaskLater(this, () -> {
if (spigotVersion != null && !PluginConfig.shouldSuppressUpdateMessages()) {
StringUtils.Version currentVersion = new StringUtils.Version(getDescription().getVersion());
StringUtils.Version latestVersion = new StringUtils.Version(spigotVersion);
if (currentVersion.compareTo(latestVersion) < 0) {
getLogger().log(Level.WARNING, "You're running an outdated version of PySpigot. The latest version is " + spigotVersion + ".");
getLogger().log(Level.WARNING, "Download it here: https://www.spigotmc.org/resources/pyspigot.111006/");
}
}
}, 20L);
versionCheckTask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::fetchSpigotVersion, 864000L, 864000L);
}

@Override
Expand Down

0 comments on commit 9cdafab

Please sign in to comment.