A bunch of rather random changes

This commit is contained in:
Daniil Z committed 2021-03-01 01:01:51 +03:00
1 parent b466373ff4
commit 7005b4cd7e
19 files changed
+179 -208

No files matched your search

@@ -30,10 +30,18 @@ import me.william278.huskhomes2.integrations.DynMapIntegration;
import me.william278.huskhomes2.integrations.VaultIntegration;
import me.william278.huskhomes2.listeners.PlayerListener;
import me.william278.huskhomes2.migrators.LegacyMigrator;
import me.william278.huskhomes2.teleport.SettingHandler;
import me.william278.huskhomes2.teleport.TeleportRequestHandler;
import org.bstats.bukkit.MetricsLite;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public final class HuskHomes extends JavaPlugin {
private static HuskHomes instance;
@@ -132,7 +140,7 @@ public final class HuskHomes extends JavaPlugin {
// Check for updates (if enabled)
if (HuskHomes.settings.doUpdateChecks()) {
getLogger().info(VersionChecker.getVersionCheckString());
getLogger().info(getVersionCheckString());
}
// Fetch spawn location if set
@@ -169,7 +177,7 @@ public final class HuskHomes extends JavaPlugin {
registerEvents(this);
// Start Loop
RunEverySecond.startLoop();
TeleportRequestHandler.startExpiredChecker(this);
// bStats initialisation
new MetricsLite(this, 8430);
@@ -180,4 +188,21 @@ public final class HuskHomes extends JavaPlugin {
// Plugin shutdown logic
getLogger().info("Disabled HuskHomes version " + this.getDescription().getVersion());
}
public static String getVersionCheckString() {
try {
URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=83767"); // Numbers = Spigot Project ID!
URLConnection urlConnection = url.openConnection();
String latestVersion = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())).readLine();
String pluginVersion = instance.getDescription().getVersion();
if (!latestVersion.equals(pluginVersion)) {
return "An update for HuskHomes is available; v" + latestVersion + " (Currently running v" + pluginVersion + ")";
} else {
return "HuskHomes is up to date! (Version " + pluginVersion + ")";
}
} catch (IOException e) {
return "Error retrieving version information!";
}
}
}