<commit_before>package com.antarescraft.kloudy.hologuiapi;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.commons.io.IOUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import com.antarescraft.kloudy.hologuiapi.guicomponents.GUIComponent;
import com.antarescraft.kloudy.hologuiapi.guicomponents.GUIPage;
import com.antarescraft.kloudy.hologuiapi.imageprocessing.GifProcessor;
import com.antarescraft.kloudy.hologuiapi.imageprocessing.PngJpgProcessor;
import com.antarescraft.kloudy.hologuiapi.util.ConfigManager;

/**
 * Represents an external plugin using the HoloGUIAPI to create GUI pages
 */
public abstract class HoloGUIPlugin extends JavaPlugin
{	
	private HashMap<String, GUIPage> guiPages;
	private ArrayList<String> yamlFiles;
	private boolean guiPagesLoaded;
	private String minSupportedApiVersion;
	
	public HoloGUIPlugin()
	{
		guiPages = new HashMap<String, GUIPage>();
		yamlFiles = new ArrayList<String>();
		guiPagesLoaded = false;
				
		initFileStructure();
		
		CodeSource source = this.getClass().getProtectionDomain().getCodeSource();
		if(source != null) 
		{
		    URL jar = source.getLocation();
		    try
		    {
		    	ZipInputStream zip = new ZipInputStream( jar.openStream());
			    ZipEntry entry = null;
			    
				while((entry = zip.getNextEntry()) != null)
				{
				    String entryName = entry.getName();
				    if( entryName.startsWith(HoloGUIApi.PATH_TO_YAMLS) &&  entryName.endsWith(".yml") )
				    {
				    	String[] pathTokens = entryName.split("/");
				        yamlFiles.add(pathTokens[pathTokens.length-1]);
				    }
				}
				
				copyResourceConfigs();
				
			} catch (IOException e) 
		    {
				e.printStackTrace();
			}
		 }
	}
	
	/**
	 * Set the minimum version of HoloGUIApi that the plugin can run on
	 */
	public void setMinSupportedApiVersion(String version)
	{
		this.minSupportedApiVersion = version;
	}
	
	/**
	 * @return true or false if the the version of HoloGUIApi installed on the server
	 * meets the minimum required api version specified by this plugin
	 */
	public boolean hasMinApiVersion()
	{
		return (getHoloGUIApi().getDescription().getVersion().compareTo(minSupportedApiVersion) > 0);
	}<commit_msg>added version number null checking<commit_after>package com.antarescraft.kloudy.hologuiapi;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.apache.commons.io.IOUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import com.antarescraft.kloudy.hologuiapi.guicomponents.GUIComponent;
import com.antarescraft.kloudy.hologuiapi.guicomponents.GUIPage;
import com.antarescraft.kloudy.hologuiapi.imageprocessing.GifProcessor;
import com.antarescraft.kloudy.hologuiapi.imageprocessing.PngJpgProcessor;
import com.antarescraft.kloudy.hologuiapi.util.ConfigManager;

/**
 * Represents an external plugin using the HoloGUIAPI to create GUI pages
 */
public abstract class HoloGUIPlugin extends JavaPlugin
{	
	private HashMap<String, GUIPage> guiPages;
	private ArrayList<String> yamlFiles;
	private boolean guiPagesLoaded;
	private String minSupportedApiVersion = "1.0";
	
	public HoloGUIPlugin()
	{
		guiPages = new HashMap<String, GUIPage>();
		yamlFiles = new ArrayList<String>();
		guiPagesLoaded = false;
				
		initFileStructure();
		
		CodeSource source = this.getClass().getProtectionDomain().getCodeSource();
		if(source != null) 
		{
		    URL jar = source.getLocation();
		    try
		    {
		    	ZipInputStream zip = new ZipInputStream( jar.openStream());
			    ZipEntry entry = null;
			    
				while((entry = zip.getNextEntry()) != null)
				{
				    String entryName = entry.getName();
				    if( entryName.startsWith(HoloGUIApi.PATH_TO_YAMLS) &&  entryName.endsWith(".yml") )
				    {
				    	String[] pathTokens = entryName.split("/");
				        yamlFiles.add(pathTokens[pathTokens.length-1]);
				    }
				}
				
				copyResourceConfigs();
				
			} catch (IOException e) 
		    {
				e.printStackTrace();
			}
		 }
	}
	
	/**
	 * Set the minimum version of HoloGUIApi that the plugin can run on
	 */
	public void setMinSupportedApiVersion(String version)
	{
		this.minSupportedApiVersion = version;
	}
	
	/**
	 * @return true or false if the the version of HoloGUIApi installed on the server
	 * meets the minimum required api version specified by this plugin
	 */
	public boolean hasMinApiVersion()
	{
		if(minSupportedApiVersion == null) minSupportedApiVersion = "1.0";
		
		return (getHoloGUIApi().getDescription().getVersion().compareTo(minSupportedApiVersion) > 0);
	}
{'fraction_non_alphanumeric': 0.10407960199004974, 'fraction_numerical': 0.0015920398009950248, 'mean_word_length': 3.9566074950690333, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4624445', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1555, 'n_words': 335}