<commit_before>package de.st_ddt.crazyutil.modules.permissions;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import de.st_ddt.crazyutil.modules.Module;

public class PermissionModule implements Module
{

	public final static List<Class<? extends PermissionSystem>> PERMISSIONSYSTEMS = new ArrayList<Class<? extends PermissionSystem>>();
	static
	{
		PERMISSIONSYSTEMS.add(PermissionVaultSystem.class);
		PERMISSIONSYSTEMS.add(PermissionPermissionsExSystem.class);
		PERMISSIONSYSTEMS.add(PermissionGroupManagerSystem.class);
		PERMISSIONSYSTEMS.add(PermissionbPermissionsSystem.class);
		PERMISSIONSYSTEMS.add(PermissionPermissionsBukkitSystem.class);
		PERMISSIONSYSTEMS.add(PermissionBukkitSystem.class);
	}
	private static PermissionSystem permissionModule;

	public static void init(final String chatHeader, final CommandSender sender)
	{
		if (permissionModule == null)
			new PermissionModule().initialize(chatHeader, sender);
	}

	public PermissionSystem getPermissionSystem()
	{
		return permissionModule;
	}

	public static void setPermissionModule(final PermissionSystem permissionModule)
	{
		PermissionModule.permissionModule = permissionModule;
	}

	public static boolean hasPermission(final CommandSender sender, final String permission)
	{
		try
		{
			return permissionModule.hasPermission(sender, permission);
		}
		catch (final Exception e)
		{
			return false;
		}
	}

	public static boolean hasGroup(final Player player, final String name)
	{
		try
		{
			return permissionModule.hasGroup(player, name);
		}
		catch (final Exception e)
		{
			return false;
		}
	}

	public static String getGroup(final Player player)
	{
		try
		{
			return permissionModule.getGroup(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static String getGroupPrefix(final Player player)
	{
		try
		{
			return permissionModule.getGroupPrefix(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static String getGroupSuffix(final Player player)
	{
		try
		{
			return permissionModule.getGroupSuffix(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static Set<String> getGroups(final Player player)
	{
		try
		{
			return permissionModule.getGroups(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public PermissionModule()
	{
		super();
		MODULES.put("permission", this);
	}

	@Override
	public boolean initialize(final String chatHeader, final CommandSender sender)
	{
		sender.sendMessage(chatHeader + "Checking permission modules:");
		for (final Class<? extends PermissionSystem> clazz : PERMISSIONSYSTEMS)
		{
			final String name = clazz.getAnnotation(Named.class).name();
			sender.sendMessage(chatHeader + ChatColor.YELLOW + "- " + name);
			if (registerPermissionModule(clazz))
			{
				sender.sendMessage(chatHeader + "Activated " + ChatColor.GREEN + permissionModule.getName() + ChatColor.WHITE + " Permission Module!");
				return true;
			}
		}
		return false;
	}

	public static boolean registerPermissionModule(final Class<? extends PermissionSystem> clazz)
	{
		final PluginDepency plugin = clazz.getAnnotation(PluginDepency.class);
		if (plugin != null)
			if (Bukkit.getPluginManager().getPlugin(plugin.depend()) == null)
				return false;
		try
		{
			permissionModule = clazz.newInstance();
			return true;
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public final String getName()<commit_msg>CrazyPlugins: check whether plugins are enabled instead of checking whether they are installed or not<commit_after>package de.st_ddt.crazyutil.modules.permissions;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import de.st_ddt.crazyutil.modules.Module;

public class PermissionModule implements Module
{

	public final static List<Class<? extends PermissionSystem>> PERMISSIONSYSTEMS = new ArrayList<Class<? extends PermissionSystem>>();
	static
	{
		PERMISSIONSYSTEMS.add(PermissionVaultSystem.class);
		PERMISSIONSYSTEMS.add(PermissionPermissionsExSystem.class);
		PERMISSIONSYSTEMS.add(PermissionGroupManagerSystem.class);
		PERMISSIONSYSTEMS.add(PermissionbPermissionsSystem.class);
		PERMISSIONSYSTEMS.add(PermissionPermissionsBukkitSystem.class);
		PERMISSIONSYSTEMS.add(PermissionBukkitSystem.class);
	}
	private static PermissionSystem permissionModule;

	public static void init(final String chatHeader, final CommandSender sender)
	{
		if (permissionModule == null)
			new PermissionModule().initialize(chatHeader, sender);
	}

	public PermissionSystem getPermissionSystem()
	{
		return permissionModule;
	}

	public static void setPermissionModule(final PermissionSystem permissionModule)
	{
		PermissionModule.permissionModule = permissionModule;
	}

	public static boolean hasPermission(final CommandSender sender, final String permission)
	{
		try
		{
			return permissionModule.hasPermission(sender, permission);
		}
		catch (final Exception e)
		{
			return false;
		}
	}

	public static boolean hasGroup(final Player player, final String name)
	{
		try
		{
			return permissionModule.hasGroup(player, name);
		}
		catch (final Exception e)
		{
			return false;
		}
	}

	public static String getGroup(final Player player)
	{
		try
		{
			return permissionModule.getGroup(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static String getGroupPrefix(final Player player)
	{
		try
		{
			return permissionModule.getGroupPrefix(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static String getGroupSuffix(final Player player)
	{
		try
		{
			return permissionModule.getGroupSuffix(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public static Set<String> getGroups(final Player player)
	{
		try
		{
			return permissionModule.getGroups(player);
		}
		catch (final Exception e)
		{
			return null;
		}
	}

	public PermissionModule()
	{
		super();
		MODULES.put("permission", this);
	}

	@Override
	public boolean initialize(final String chatHeader, final CommandSender sender)
	{
		sender.sendMessage(chatHeader + "Checking permission modules:");
		for (final Class<? extends PermissionSystem> clazz : PERMISSIONSYSTEMS)
		{
			final String name = clazz.getAnnotation(Named.class).name();
			sender.sendMessage(chatHeader + ChatColor.YELLOW + "- " + name);
			if (registerPermissionModule(clazz))
			{
				sender.sendMessage(chatHeader + "Activated " + ChatColor.GREEN + permissionModule.getName() + ChatColor.WHITE + " Permission Module!");
				return true;
			}
		}
		return false;
	}

	public static boolean registerPermissionModule(final Class<? extends PermissionSystem> clazz)
	{
		final PluginDepency plugin = clazz.getAnnotation(PluginDepency.class);
		if (plugin != null)
			if (!Bukkit.getPluginManager().isPluginEnabled(plugin.depend()))
				return false;
		try
		{
			permissionModule = clazz.newInstance();
			return true;
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public final String getName()
{'fraction_non_alphanumeric': 0.09322611421561947, 'fraction_numerical': 0.0, 'mean_word_length': 4.513148009015778, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4153783', 'n_tokens_mistral': 2497, 'n_tokens_neox': 2180, 'n_words': 518}