From 68a53a8760b6e90191f82e2bfdb202f6fd754475 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 24 Oct 2018 10:11:37 +1300 Subject: [PATCH] Add version logging for premium check --- .../disguise/utilities/LibsPremium.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java b/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java index 0d32d66f..59a1698f 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/LibsPremium.java @@ -1,6 +1,10 @@ package me.libraryaddict.disguise.utilities; +import org.apache.commons.io.IOUtils; +import org.bukkit.configuration.file.YamlConfiguration; + import java.io.File; +import java.io.InputStream; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; @@ -36,17 +40,30 @@ public class LibsPremium { Method m = c.getMethod("isPremium"); thisPluginIsPaidFor = (Boolean) m.invoke(null); + String pluginVersion; + + try (InputStream stream = cl.getResourceAsStream("plugin.yml")) { + YamlConfiguration config = new YamlConfiguration(); + config.loadFromString(IOUtils.toString(stream, "UTF-8")); + + pluginVersion = config.getString("version"); + } if (isPremium()) { - DisguiseUtilities.getLogger().info("Found a premium Lib's Disguises jar, premium enabled!"); + // Found a premium Lib's Disguises jar (v5.2.6), premium enabled! + DisguiseUtilities.getLogger() + .info("Found a premium Lib's Disguises jar (v" + pluginVersion + "), premium enabled!"); break; } else { + // You have a non-premium Lib's Disguises jar (LibsDisguises.jar v5.2.6) in the folder! DisguiseUtilities.getLogger().warning( - "You have a non-premium Lib's Disguises jar (" + file.getName() + ") in the folder!"); + "You have a non-premium Lib's Disguises jar (" + file.getName() + " v" + pluginVersion + + ") in the folder!"); } } catch (Exception ex) { + ex.printStackTrace(); // Don't print off errors } }