From 819487743cdac7ce952ba3b9a7c4a910d58db97b Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 4 Feb 2018 01:18:11 +1300 Subject: [PATCH] Updated Lib's Premium to remove one import and close the UrlClassLoader --- src/me/libraryaddict/disguise/LibsDisguises.java | 2 +- src/me/libraryaddict/disguise/utilities/LibsPremium.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 056497b6..91fe33c1 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -37,7 +37,7 @@ public class LibsDisguises extends JavaPlugin { saveResource("disguises.yml", false); } - LibsPremium.check(instance); + LibsPremium.check(getDescription().getVersion()); PacketsManager.init(this); DisguiseUtilities.init(this); diff --git a/src/me/libraryaddict/disguise/utilities/LibsPremium.java b/src/me/libraryaddict/disguise/utilities/LibsPremium.java index 8cf34580..01284279 100644 --- a/src/me/libraryaddict/disguise/utilities/LibsPremium.java +++ b/src/me/libraryaddict/disguise/utilities/LibsPremium.java @@ -1,7 +1,5 @@ package me.libraryaddict.disguise.utilities; -import me.libraryaddict.disguise.LibsDisguises; - import java.io.File; import java.lang.reflect.Method; import java.net.URL; @@ -35,10 +33,10 @@ public class LibsPremium { return thisPluginIsPaidFor == null ? !"%%__USER__%%".contains("__USER__") : thisPluginIsPaidFor; } - public static void check(LibsDisguises disguises) { + public static void check(String version) { thisPluginIsPaidFor = isPremium(); - if (!isPremium() && disguises.getDescription().getVersion().contains("SNAPSHOT")) { + if (!isPremium() && version.contains("SNAPSHOT")) { File[] files = new File("plugins/LibsDisguises/").listFiles(); if (files == null) @@ -51,8 +49,7 @@ public class LibsPremium { if (!file.getName().endsWith(".jar")) continue; - try { - ClassLoader cl = new URLClassLoader(new URL[]{file.toURI().toURL()}); + try (URLClassLoader cl = new URLClassLoader(new URL[]{file.toURI().toURL()})) { Class c = cl.loadClass(LibsPremium.class.getName()); Method m = c.getMethod("isPremium");