org.bukkit.plugin.InvalidDescriptionException Java Examples

The following examples show how to use org.bukkit.plugin.InvalidDescriptionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PGMServer.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws InvalidDescriptionException {
  BasicConfigurator.configure();
  new PGMServer(
          new PluginDescriptionFile(
              Thread.currentThread().getContextClassLoader().getResourceAsStream("plugin.yml")))
      .run();
}
 
Example #2
Source File: Updater.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
public static void replaceTheJar(byte[] data) throws RuntimeException, IOException {
    File pluginFolder = new File("plugins");
    if (!pluginFolder.exists()) {
        throw new RuntimeException("Can't find the plugins folder.");
    }
    if (!pluginFolder.isDirectory()) {
        throw new RuntimeException("Plugins not a folder.");
    }
    File[] plugins = pluginFolder.listFiles();
    if (plugins == null) {
        throw new IOException("Can't get the files in plugins folder");
    }
    File quickshop = null;
    for (File plugin : plugins) {
        try {
            PluginDescriptionFile desc =
                    QuickShop.instance.getPluginLoader().getPluginDescription(plugin);
            if (!desc.getName().equals(QuickShop.instance.getDescription().getName())) {
                continue;
            }
            Util.debugLog("Selected: " + plugin.getPath());
            quickshop = plugin;
            break;
        } catch (InvalidDescriptionException e) { // Ignore }
        }
    }
    if (quickshop == null) {
        throw new RuntimeException("Failed to get QuickShop Jar File.");
    }
    OutputStream outputStream = new FileOutputStream(quickshop, false);
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();
}
 
Example #3
Source File: PlanBukkitMocker.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
PlanBukkitMocker withPluginDescription() {
    try (InputStream in = Files.newInputStream(getFile("/plugin.yml").toPath())) {
        PluginDescriptionFile description = new PluginDescriptionFile(in);
        doReturn(description).when(planMock).getDescription();
    } catch (IOException | InvalidDescriptionException e) {
        System.out.println("Error while setting plugin description");
    }
    return this;
}
 
Example #4
Source File: LukkitPluginFile.java    From Lukkit with MIT License 5 votes vote down vote up
/**
 * Gets the plugin.yml equivalent for Lukkit plugins (plugin.yml)
 *
 * @return the config
 */
public InputStream getPluginYML() throws InvalidDescriptionException {
    InputStream pluginYml = this.getResource("plugin.yml");
    if (pluginYml == null)
        throw new InvalidDescriptionException("The description provided was missing.");
    return pluginYml;
}
 
Example #5
Source File: RuntimePluginLoader.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException {
  return loader.getPluginDescription(file);
}
 
Example #6
Source File: LoggedPluginManager.java    From VoxelGamesLibv2 with MIT License 4 votes vote down vote up
@Override
public Plugin loadPlugin(File file)
        throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
    return delegate.loadPlugin(file);
}
 
Example #7
Source File: LoggedPluginManager.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
	return delegate.loadPlugin(file);
}
 
Example #8
Source File: Main.java    From Lukkit with MIT License 4 votes vote down vote up
@Override
public void onLoad() {
    // Set the logger and instance
    logger = this.getLogger();
    instance = this;

    // Create the data folder directory if it doesn't exist
    if (!this.getDataFolder().exists()) //noinspection ResultOfMethodCallIgnored
        this.getDataFolder().mkdir();

    // Check the config
    this.checkConfig();

    // Initialize the Lua env (sets up globals)
    LuaEnvironment.init(this.getConfig().getBoolean("lua-debug"));

    // Save the plugin manager for future use
    this.pluginManager = this.getServer().getPluginManager();
    // Register our custom plugin loader on the plugin manager
    this.pluginManager.registerInterface(LukkitPluginLoader.class);

    this.getLogger().info("Loading Lukkit plugins...");

    // Get the files in the plugins directory
    File[] plugins = this.getFile().getParentFile().listFiles();

    if (plugins != null) {
        // Set the start time of loading
        long startTime = System.currentTimeMillis();

        for (File file : plugins) {
            // "break" if the file isn't for Lukkit
            if (isLukkitPluginFile(file.getName())) {
                // Load the plugin using LukkitPluginLoader
                try {
                    this.pluginManager.loadPlugin(file);
                } catch (InvalidPluginException | InvalidDescriptionException e) {
                    LuaEnvironment.addError(e);
                    e.printStackTrace();
                }
            }
        }

        // Get the total time to load plugins and save to loadTime member
        loadTime = System.currentTimeMillis() - startTime;
    }

    for (Plugin plugin : this.pluginManager.getPlugins()) {
        if (plugin instanceof LukkitPlugin) {
            this.pluginLoader = (LukkitPluginLoader) plugin.getPluginLoader();
            break;
        }
    }
}