How to load a plugin from a string?

Discussion in 'Plugin Development' started by Bammerbom, Jul 28, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Bammerbom

    I tried something like this.
    Code:
    Plugin p = pm.getPlugin(args[0]);
    pm.loadPlugin(p);
    But I can't convert String > Plugin or String > File
    Please post a code
     
  2. Offline

    microgeek

    Nobody is going to just hand you code. Look into the following classes: JarFile, JarEntry and URLClassLoader.
     
  3. Offline

    Bammerbom

  4. Offline

    Polaris29

    Jhtzb
    String to file is "new File(String)"
    Also, you can't get a plugin if it isn't loaded.

    Try using something like this:
    Code:java
    1.  
    2. Plugin p = null;
    3. WorldEditPlugin we = null;
    4. try {
    5. p = Bukkit.getServer().getPluginManager().loadPlugin(new File("plugins/WorldEdit.jar"));
    6. we = (WorldEditPlugin) p;
    7. } catch (UnknownDependencyException | InvalidPluginException
    8. | InvalidDescriptionException e1) {
    9. e1.printStackTrace();
    10. }
    11.  
     
Thread Status:
Not open for further replies.

Share This Page