/FileExtraction/Java_unseen/Wind-Development_WindSpigot/WindSpigot-Server/src/main/java/xyz/sculas/nacho/malware/AntiMalware.java
package xyz.sculas.nacho.malware;

import org.bukkit.plugin.Plugin;

import ga.windpvp.windspigot.commons.ClassUtils;

public class AntiMalware {
	
	private static final String javaAssist = new String(new char[] { 'j', 'a', 'v', 'a', 's', 's', 'i', 's', 't', '.', 'w', 's' });

	public static void find(Plugin plugin) {
		Class<? extends Plugin> clazz = plugin.getClass();
		boolean foundL10 = ClassUtils.exists(clazz.getName() + "L10", plugin.getClass().getClassLoader());
		boolean foundWS = findJavaWS(plugin);
		if (foundL10 && foundWS) {
			throw new IllegalStateException("MALWARE FOUND IN PLUGIN: " + plugin.getName());
		}
	}

	private static boolean findJavaWS(Plugin plugin) {
		return ClassUtils.exists(javaAssist + ".a", plugin.getClass().getClassLoader())
				&& ClassUtils.exists(javaAssist + ".b", plugin.getClass().getClassLoader())
				&& ClassUtils.exists(javaAssist + ".c", plugin.getClass().getClassLoader())
				&& ClassUtils.exists(javaAssist + ".d", plugin.getClass().getClassLoader());
	}

}
