Config Update

This commit is contained in:
wherkamp 2018-04-02 13:52:59 -04:00
parent a5200fd5c1
commit 63151dc800
2 changed files with 26 additions and 16 deletions

View File

@ -19,17 +19,17 @@ import java.util.regex.Pattern;
*/
public class UpdateChecker implements Listener {
private PlaceholderAPIPlugin plugin;
private PlaceholderAPIPlugin plugin;
private final int resourceId = 6245;
private static String latestVersion = "";
private static boolean updateAvailable = false;
public UpdateChecker(PlaceholderAPIPlugin i) {
plugin = i;
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin = i;
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if (checkForUpdate()) {
Bukkit.getScheduler().runTask(plugin, () -> {
plugin.getLogger().info("An update for PlaceholderAPI (v" + getLatestVersion() + ") is available at:");
@ -39,17 +39,19 @@ public class UpdateChecker implements Listener {
}
});
}
private void register() {
Bukkit.getPluginManager().registerEvents(this, plugin);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent e) {
if (e.getPlayer().hasPermission("placeholderapi.updatenotify")) {
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAn update for &fPlaceholder&7API &e(&fPlaceholder&7API &fv" + getLatestVersion() + "&e)"));
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bis available at &ehttps://www.spigotmc.org/resources/placeholderapi." + resourceId + "/"));
}
if (plugin.getConfig().getBoolean("warn_admin_update")) {
if (e.getPlayer().hasPermission("placeholderapi.updatenotify")) {
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAn update for &fPlaceholder&7API &e(&fPlaceholder&7API &fv" + getLatestVersion() + "&e)"));
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bis available at &ehttps://www.spigotmc.org/resources/placeholderapi." + resourceId + "/"));
}
}
}
private String getSpigotVersion() {
@ -96,10 +98,10 @@ public class UpdateChecker implements Listener {
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
version = "";
for (String s : split) {
version += String.format("%4s", s);
}
version += String.format("%4s", s);
}
return version;
}
}

View File

@ -8,10 +8,18 @@
# Discord: https://discordapp.com/invite/7sndK3q
# No placeholders are provided with this plugin by default.
# Download placeholders: /papi ecloud
# Check if plugin is up to date
check_updates: true
# Warn the admin if the plugin is out of date
warn_admin_update: true
# PlaceHolder cloud enabled
cloud_enabled: true
# Allow unverified Expansions
cloud_allow_unverified_expansions: false
# Alternative meaning for true and false
boolean:
'true': 'yes'
'false': 'no'
# How you want to date formatted
date_format: MM/dd/yy HH:mm:ss