mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Added config option for version checker
This commit is contained in:
1 parent
9a595efabf
commit
95b762e283
5 files changed
+16
-30
No files matched your search
@@ -116,9 +116,6 @@ public final class HuskHomes extends JavaPlugin {
|
||||
// Set instance for easy cross-class referencing
|
||||
setInstance(this);
|
||||
|
||||
// Check if HuskHomes is up-to-date
|
||||
getLogger().info(versionChecker.getVersionCheckString());
|
||||
|
||||
// MIGRATION: Check if a migration needs to occur
|
||||
legacyVersionMigrator.checkStartupMigration();
|
||||
|
||||
@@ -133,6 +130,11 @@ public final class HuskHomes extends JavaPlugin {
|
||||
// Load the messages (in the right language)
|
||||
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||
|
||||
// Check for updates (if enabled)
|
||||
if (HuskHomes.settings.doUpdateChecks()) {
|
||||
getLogger().info(versionChecker.getVersionCheckString());
|
||||
}
|
||||
|
||||
// Fetch spawn location if set
|
||||
settingHandler.fetchSpawnLocation();
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ public class Settings {
|
||||
// Message language setting
|
||||
String language;
|
||||
|
||||
// Automatically send update HuskHomes reminders
|
||||
boolean updateReminders;
|
||||
|
||||
// Bungee settings
|
||||
boolean doBungee;
|
||||
String server;
|
||||
@@ -77,6 +80,8 @@ public class Settings {
|
||||
try {
|
||||
this.language = configFile.getString("language");
|
||||
|
||||
this.updateReminders = configFile.getBoolean("check_for_updates");
|
||||
|
||||
this.doBungee = configFile.getBoolean("bungee_options.enable_bungee_mode");
|
||||
this.server = configFile.getString("bungee_options.server_id");
|
||||
|
||||
@@ -339,4 +344,8 @@ public class Settings {
|
||||
public Sound getTeleportCancelledSound() {
|
||||
return teleportCancelledSound;
|
||||
}
|
||||
|
||||
public boolean doUpdateChecks() {
|
||||
return updateReminders;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,14 @@
|
||||
package me.william278.huskhomes2;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
||||
|
||||
public class versionChecker {
|
||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||
|
||||
public static void adminVersionCheck(Player p) {
|
||||
if (p.hasPermission("huskhomes.version_checker")) {
|
||||
if (!versionChecker.getVersionCheckString().contains("HuskHomes is up to date!")) {
|
||||
p.sendMessage(ChatColor.DARK_RED + "Update: " + ChatColor.RED + versionChecker.getVersionCheckString());
|
||||
|
||||
// Send a link to Spigot downloads page
|
||||
ComponentBuilder componentBuilder = new ComponentBuilder();
|
||||
TextComponent projectURL = new TextComponent("[Download]");
|
||||
ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates");
|
||||
projectURL.setClickEvent(clickEvent);
|
||||
projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA);
|
||||
componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: "));
|
||||
componentBuilder = componentBuilder.append(projectURL);
|
||||
p.spigot().sendMessage(componentBuilder.create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersionCheckString() {
|
||||
try {
|
||||
URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=83767"); // Numbers = Spigot Project ID!
|
||||
|
||||
Reference in new issue
Block a user