mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-30 06:33:27 +01:00
.
This commit is contained in:
parent
78bd31209b
commit
8489cf0e4b
@ -29,6 +29,12 @@ show-message-when-using-chest-and-sorting-is-enabled: false
|
||||
# logs out and back in and then uses a chest again.
|
||||
show-message-again-after-logout: true
|
||||
|
||||
# should we check for updates on server startup?
|
||||
# when enabled, a message is printed in the console if a new
|
||||
# version has been found, and OPs will be notified when they
|
||||
# join the server
|
||||
check-for-updates: true
|
||||
|
||||
##########################
|
||||
##### Sorting Method #####
|
||||
##########################
|
||||
|
@ -31,12 +31,17 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
JeffChestSortCommandExecutor commandExecutor = new JeffChestSortCommandExecutor(this);
|
||||
this.getCommand("chestsort").setExecutor(commandExecutor);
|
||||
|
||||
if(getConfig().getBoolean("check-for-updates",true)) {
|
||||
updateChecker.checkForUpdate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
//metrics.addCustomChart(new Metrics.SimplePie("bukkit_version", () -> getServer().getBukkitVersion()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("sorting_method", () -> sortingMethod));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("config_version", () -> Integer.toString(getConfig().getInt("config-version",0))));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("check_for_updates", () -> Boolean.toString(getConfig().getBoolean("check-for-updates",true))));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("show_message_when_using_chest", () -> Boolean.toString(getConfig().getBoolean("show-message-when-using-chest"))));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("show_message_again_after_logout", () -> Boolean.toString(getConfig().getBoolean("show-message-again-after-logout"))));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("sorting_enabled_by_default", () -> Boolean.toString(getConfig().getBoolean("sorting-enabled-by-default"))));
|
||||
@ -55,7 +60,7 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
getLogger().warning("========================================================");
|
||||
}
|
||||
|
||||
updateChecker.checkForUpdate();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +85,7 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
getConfig().addDefault("show-message-when-using-chest-and-sorting-is-enabled", false);
|
||||
getConfig().addDefault("show-message-again-after-logout", true);
|
||||
getConfig().addDefault("sorting-method", "{itemsFirst},{name},{color}");
|
||||
getConfig().addDefault("check-for-updates", true);
|
||||
}
|
||||
|
||||
void unregisterPlayer(Player p) {
|
||||
|
@ -18,13 +18,16 @@ public class JeffChestSortUpdateChecker {
|
||||
|
||||
String latestVersionLink = "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt";
|
||||
String downloadLink = "https://www.spigotmc.org/resources/1-13-chestsort.59773/";
|
||||
private String currentVersion;
|
||||
private String latestVersion;
|
||||
private String currentVersion = "undefined";
|
||||
private String latestVersion = "undefined";
|
||||
|
||||
public void sendUpdateMessage(Player p) {
|
||||
if(!latestVersion.equals("undefined")) {
|
||||
if (!currentVersion.equals(latestVersion)) {
|
||||
p.sendMessage(ChatColor.GRAY + "There is a new version of " + ChatColor.GOLD + "ChestSort" + ChatColor.GRAY
|
||||
+ " available. Please download at " + downloadLink);
|
||||
+ " available.");
|
||||
p.sendMessage(ChatColor.GRAY + "Please download at " + downloadLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,17 +44,20 @@ public class JeffChestSortUpdateChecker {
|
||||
|
||||
String inputLine = reader.readLine().trim();
|
||||
|
||||
currentVersion = plugin.getDescription().getVersion().trim();
|
||||
latestVersion = inputLine;
|
||||
currentVersion = plugin.getDescription().getVersion().trim();
|
||||
|
||||
plugin.getLogger().info("Latest : " + inputLine);
|
||||
plugin.getLogger().info("Current: " + currentVersion);
|
||||
|
||||
if (latestVersion.equals(currentVersion)) {
|
||||
plugin.getLogger().info("You are using the latest version of ChestSort.");
|
||||
} else {
|
||||
plugin.getLogger().warning("========================================================");
|
||||
plugin.getLogger().warning("There is a new version of ChestSort available!");
|
||||
plugin.getLogger().warning("Latest : " + inputLine);
|
||||
plugin.getLogger().warning("Current: " + currentVersion);
|
||||
plugin.getLogger().warning("Please update to the newest version. Download:");
|
||||
plugin.getLogger().warning(downloadLink);
|
||||
plugin.getLogger().warning("========================================================");
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
Loading…
Reference in New Issue
Block a user