2017-06-02 15:51:03 +02:00
|
|
|
package me.libraryaddict.disguise.utilities;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URLClassLoader;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by libraryaddict on 2/06/2017.
|
|
|
|
*/
|
2017-06-08 17:09:28 +02:00
|
|
|
public class LibsPremium {
|
2017-06-02 15:51:03 +02:00
|
|
|
private static Boolean thisPluginIsPaidFor;
|
|
|
|
|
|
|
|
public static Boolean isPremium() {
|
|
|
|
return thisPluginIsPaidFor == null ? !"%%__USER__%%".contains("__USER__") : thisPluginIsPaidFor;
|
|
|
|
}
|
|
|
|
|
2018-02-03 13:18:11 +01:00
|
|
|
public static void check(String version) {
|
2017-06-02 15:51:03 +02:00
|
|
|
thisPluginIsPaidFor = isPremium();
|
|
|
|
|
2018-08-05 10:34:02 +02:00
|
|
|
if (!isPremium()) {
|
2017-06-08 17:06:58 +02:00
|
|
|
File[] files = new File("plugins/LibsDisguises/").listFiles();
|
|
|
|
|
|
|
|
if (files == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (File file : files) {
|
2017-06-02 15:51:03 +02:00
|
|
|
if (!file.isFile())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!file.getName().endsWith(".jar"))
|
|
|
|
continue;
|
|
|
|
|
2018-02-03 13:18:11 +01:00
|
|
|
try (URLClassLoader cl = new URLClassLoader(new URL[]{file.toURI().toURL()})) {
|
2017-06-08 17:09:28 +02:00
|
|
|
Class c = cl.loadClass(LibsPremium.class.getName());
|
2017-06-02 15:51:03 +02:00
|
|
|
|
|
|
|
Method m = c.getMethod("isPremium");
|
|
|
|
thisPluginIsPaidFor = (Boolean) m.invoke(null);
|
|
|
|
|
2018-02-15 22:51:15 +01:00
|
|
|
if (isPremium()) {
|
2018-08-14 02:42:35 +02:00
|
|
|
DisguiseUtilities.getLogger().info("Found a premium Lib's Disguises jar, premium enabled!");
|
2018-02-15 22:51:15 +01:00
|
|
|
|
2017-06-02 15:51:03 +02:00
|
|
|
break;
|
2018-02-15 22:51:15 +01:00
|
|
|
} else {
|
2018-09-13 08:56:46 +02:00
|
|
|
DisguiseUtilities.getLogger().warning(
|
|
|
|
"You have a non-premium Lib's Disguises jar (" + file.getName() + ") in the folder!");
|
2018-02-15 22:51:15 +01:00
|
|
|
}
|
2017-06-02 15:51:03 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
// Don't print off errors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|