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 {
|
2018-04-23 11:02:20 +02:00
|
|
|
// I believe I was tired and frustrated when I wrote this, but leaving it in because it's an entertaining read.
|
|
|
|
|
2017-06-02 15:51:03 +02:00
|
|
|
/**
|
|
|
|
* If you're seriously going to modify this to get the premium stuff for free, can you at least not
|
|
|
|
* distribute it? You didn't pay for it despite how cheap it is. You spend $8 on a trip to McDonalds
|
|
|
|
* but you balk at the idea of actually supporting someone when you can just steal it for free.
|
|
|
|
* Is the only reason you don't rob McDonalds because they can catch you? Is the only reason you don't rob your
|
|
|
|
* Grandma being that she knows who was in her house? If you see someone's credit card drop out their pocket,
|
|
|
|
* you planning on taking it and going shopping?
|
|
|
|
* Do you really have the right to give someones work away for free?
|
|
|
|
* You know enough to start coding, but you resist the idea of contributing to this plugin. Its even
|
|
|
|
* open-source, no one is stopping you. You're the guy who files a bug report because the hacked version has
|
|
|
|
* malware installed.
|
|
|
|
* I'd hate to work with you.
|
|
|
|
*/
|
|
|
|
private static Boolean thisPluginIsPaidFor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Don't even think about disabling this unless you purchased the premium plugin. It will uh, corrupt your server
|
|
|
|
* and stuff. Also my dog will cry because I can't afford to feed him. And my sister will be beaten by my dad
|
|
|
|
* again because I'm not bringing enough money in.
|
|
|
|
*/
|
|
|
|
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-05 10:34:02 +02:00
|
|
|
System.out.println("[LibsDisguises] 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 {
|
|
|
|
System.out.println("[LibsDisguises] You have a non-premium Lib's Disguises jar in the folder!");
|
|
|
|
}
|
2017-06-02 15:51:03 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
// Don't print off errors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|