mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 14:38:53 +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
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.William278</groupId>
|
<groupId>me.William278</groupId>
|
||||||
<artifactId>HuskHomes</artifactId>
|
<artifactId>HuskHomes</artifactId>
|
||||||
<version>2.1.2</version>
|
<version>2.1.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HuskHomes</name>
|
<name>HuskHomes</name>
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
// Set instance for easy cross-class referencing
|
// Set instance for easy cross-class referencing
|
||||||
setInstance(this);
|
setInstance(this);
|
||||||
|
|
||||||
// Check if HuskHomes is up-to-date
|
|
||||||
getLogger().info(versionChecker.getVersionCheckString());
|
|
||||||
|
|
||||||
// MIGRATION: Check if a migration needs to occur
|
// MIGRATION: Check if a migration needs to occur
|
||||||
legacyVersionMigrator.checkStartupMigration();
|
legacyVersionMigrator.checkStartupMigration();
|
||||||
|
|
||||||
@@ -133,6 +130,11 @@ public final class HuskHomes extends JavaPlugin {
|
|||||||
// Load the messages (in the right language)
|
// Load the messages (in the right language)
|
||||||
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
messageManager.loadMessages(HuskHomes.settings.getLanguage());
|
||||||
|
|
||||||
|
// Check for updates (if enabled)
|
||||||
|
if (HuskHomes.settings.doUpdateChecks()) {
|
||||||
|
getLogger().info(versionChecker.getVersionCheckString());
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch spawn location if set
|
// Fetch spawn location if set
|
||||||
settingHandler.fetchSpawnLocation();
|
settingHandler.fetchSpawnLocation();
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ public class Settings {
|
|||||||
// Message language setting
|
// Message language setting
|
||||||
String language;
|
String language;
|
||||||
|
|
||||||
|
// Automatically send update HuskHomes reminders
|
||||||
|
boolean updateReminders;
|
||||||
|
|
||||||
// Bungee settings
|
// Bungee settings
|
||||||
boolean doBungee;
|
boolean doBungee;
|
||||||
String server;
|
String server;
|
||||||
@@ -77,6 +80,8 @@ public class Settings {
|
|||||||
try {
|
try {
|
||||||
this.language = configFile.getString("language");
|
this.language = configFile.getString("language");
|
||||||
|
|
||||||
|
this.updateReminders = configFile.getBoolean("check_for_updates");
|
||||||
|
|
||||||
this.doBungee = configFile.getBoolean("bungee_options.enable_bungee_mode");
|
this.doBungee = configFile.getBoolean("bungee_options.enable_bungee_mode");
|
||||||
this.server = configFile.getString("bungee_options.server_id");
|
this.server = configFile.getString("bungee_options.server_id");
|
||||||
|
|
||||||
@@ -339,4 +344,8 @@ public class Settings {
|
|||||||
public Sound getTeleportCancelledSound() {
|
public Sound getTeleportCancelledSound() {
|
||||||
return teleportCancelledSound;
|
return teleportCancelledSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean doUpdateChecks() {
|
||||||
|
return updateReminders;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,14 @@
|
|||||||
package me.william278.huskhomes2;
|
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.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL;
|
|
||||||
|
|
||||||
public class versionChecker {
|
public class versionChecker {
|
||||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
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() {
|
public static String getVersionCheckString() {
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=83767"); // Numbers = Spigot Project ID!
|
URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=83767"); // Numbers = Spigot Project ID!
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
language: 'en-gb'
|
language: 'en-gb'
|
||||||
|
check_for_updates: true
|
||||||
data_storage_options:
|
data_storage_options:
|
||||||
storage_type: 'SQLite'
|
storage_type: 'SQLite'
|
||||||
mysql_credentials:
|
mysql_credentials:
|
||||||
|
|||||||
Reference in new issue
Block a user