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

View File

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