Java 类org.bukkit.plugin.InvalidPluginException 实例源码

项目:MCPluginDebuggerforMC    文件:SocketRunnable.java   
@Override
public void run() {
    while (true) {
        try (Socket socket = serverSocket.accept(); DataInputStream inputStream = new DataInputStream(socket.getInputStream())) {
            String name = inputStream.readUTF();
            if (!Objects.equals(pluginName, name)) continue;
            Util.unloadPlugin(Bukkit.getPluginManager().getPlugin(pluginName));
            Bukkit.getConsoleSender().sendMessage("[Debugger] Unload Plugin");
            File file = new File(pluginsFolder, pluginName + ".jar");
            byte[] buffer = new byte[512];
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            int fLength;
            while ((fLength = inputStream.read(buffer)) > 0) {
                fileOutputStream.write(buffer, 0, fLength);
            }
            fileOutputStream.flush();
            fileOutputStream.close();
            Bukkit.getConsoleSender().sendMessage("[Debugger] File Reserved");
            Util.loadPlugin(file);
            Bukkit.getConsoleSender().sendMessage("[Debugger] LoadComplete: " + pluginName);
        } catch (IOException | InvalidDescriptionException | InvalidPluginException e) {
            e.printStackTrace();
        }
    }
}
项目:MCPluginDebuggerforMC    文件:MCPluginDebugger.java   
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    switch (cmd.getName().toLowerCase()) {
        case "unload":
            Util.unloadPlugin(Bukkit.getPluginManager().getPlugin(args[0]));
            sender.sendMessage("Unloaded");
            break;
        case "load":
            try {
                Util.loadPlugin(new File(this.getDataFolder().getParent(), args[0] + ".jar"));
                sender.sendMessage("Loaded");
            } catch (InvalidDescriptionException | InvalidPluginException e) {
                e.printStackTrace();
            }
            break;
        default:
            return false;
    }
    return true;
}
项目:OMGPI    文件:OMGPI.java   
/**
 * Register all systems.
 */
@SuppressWarnings("ConstantConditions")
public void init() {
    OMGCommand.omgpi_register();
    if (mainfig.contains("mysql"))
        new MySQL(mainfig.getString("mysql.hostname"), mainfig.getString("mysql.port"), mainfig.getString("mysql.database"), mainfig.getString("mysql.username"), mainfig.getString("mysql.password"));
    iLog("Loading games...");
    OMGList<String> games = new OMGList<>();
    File gdir = new File(getDataFolder() + File.separator + "games");
    if (!gdir.exists() && gdir.mkdir()) iLog("Created games folder.");
    String[] files = gdir.list();
    if (files != null && files.length > 0) Collections.addAll(games, files);
    iLog("Games folder: " + Strings.join(games, ", "));
    games.removeIf(s -> !s.endsWith(".jar"));
    if (games.isEmpty()) {
        wLog("No game jars found in games folder. Please add GameName.jar file to /plugins/OMGPI/games/.");
        return;
    }
    String game = mainfig.getString("selectedGame", "random");
    try {
        if (game == null || !games.contains(game + ".jar")) loadGame(null);
        else loadGame(game);
    } catch (InvalidDescriptionException | InvalidPluginException e) {
        e.printStackTrace();
    }
}
项目:OMGPI    文件:OMGPI.java   
/**
 * Load game from name.
 *
 * @param game Name of a game.
 * @return Module plugin.
 * @throws InvalidDescriptionException Plugin.yml is wrong
 * @throws InvalidPluginException      Plugin cannot be loaded
 */
public Game loadGame(String game) throws InvalidDescriptionException, InvalidPluginException {
    iLog("Loading game " + game + "...");
    Plugin p;
    if (game == null) {
        OMGList<String> games = new OMGList<>();
        String[] list = new File(getDataFolder() + File.separator + "games").list();
        if (list != null) Collections.addAll(games, list);
        games.removeIf(s -> !s.endsWith(".jar"));
        iLog("Last game: " + mainfig.getString("lastGame"));
        if (games.size() > 1 && mainfig.contains("lastGame"))
            games.removeIf(s -> mainfig.getString("lastGame").equals(s.replaceAll("\\.jar", "")));
        iLog("List of runnable games: " + Strings.join(games, ", "));
        String gameName = games.get(new Random().nextInt(games.size()));
        p = Bukkit.getPluginManager().loadPlugin(new File(getDataFolder() + File.separator + "games" + File.separator + gameName));
        mainfig.set("lastGame", gameName.replaceAll("\\.jar", ""));
        mainfig.save();
    } else {
        p = Bukkit.getPluginManager().loadPlugin(new File(getDataFolder() + File.separator + "games" + File.separator + game + ".jar"));
        mainfig.set("lastGame", game);
        mainfig.save();
    }
    g = (Game) p;
    getServer().getPluginManager().enablePlugin(p);
    return (Game) p;
}
项目:economy    文件:SubPluginLoader.java   
public void loadPlugin(Plugin pl, PluginDescriptionFile description) throws InvalidPluginException {
    valid(pl);

    SubPlugin sub = (SubPlugin) pl;
    valid(sub, description);

    sub.setLoader(this);
    sub.setDescription(description);
    sub.setParent(plugin);

    val logger = plugin.getLogger();
    val log = "[Sub|" + description.getName() + "] ";

    sub.setLogger(new Logger(sub.getClass().getCanonicalName(), null) {
        public void log(LogRecord record) {
            record.setMessage(log + record.getMessage());
            logger.log(record);
        }
    });
    Fun.load(sub);
    Bukkit.getPluginManager().enablePlugin(sub);
}
项目:FastSurvival    文件:FastSurvival.java   
private boolean checkLibraries() {
    try {
        Class clazz = Class.forName("org.apache.commons.lang3.StringUtils");
    } catch (ClassNotFoundException e) {
        Bukkit.getLogger().info("Missing libraries, downloading them.");
        try {
            URL url = new URL("http://static.zyuiop.net/libs.jar");
            ReadableByteChannel rbc = Channels.newChannel(url.openStream());
            File output = new File(getFile().getParentFile(), "libs.jar");
            FileOutputStream fos = new FileOutputStream(output);
            fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

            Bukkit.getLogger().info("Downloaded, loading...");
            getPluginLoader().enablePlugin(getPluginLoader().loadPlugin(output));
            Bukkit.getLogger().info("Done !");
        } catch (InvalidPluginException | IOException e1) {
            Bukkit.getLogger().severe("Libraries download failed. Stopping.");
            e1.printStackTrace();
            return false;
        }
    }
    return true;
}
项目:CloudNet    文件:CloudServer.java   
@Override
public void onCustomSubChannelMessageReceive(String channel, String message, Document document)
{
    Bukkit.getPluginManager().callEvent(new BukkitSubChannelMessageEvent(channel, message, document));

    if (channel.equalsIgnoreCase("cloudnet_internal"))
    {
        if (message.equalsIgnoreCase("install_plugin"))
        {
            String url = document.getString("url");
            try
            {
                URLConnection urlConnection = new URL(url).openConnection();
                urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
                urlConnection.connect();
                Files.copy(urlConnection.getInputStream(), Paths.get("plugins/" + document.getString("name") + ".jar"));
                File file = new File("plugins/" + document.getString("name") + ".jar");

                Plugin plugin = Bukkit.getPluginManager().loadPlugin(file);
                Bukkit.getPluginManager().enablePlugin(plugin);
            } catch (IOException | InvalidDescriptionException | InvalidPluginException e)
            {
                e.printStackTrace();
            }
        }
    }

}
项目:MockBukkit    文件:PluginManagerMock.java   
@Override
public Plugin loadPlugin(File file)
        throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:UnlimitedPlugins    文件:UnlimitedPlugins.java   
public Plugin loadPlugin(CommandSender sender, File f, ArrayList<Plugin> loaded) {
    Plugin pl = null;
    for (Plugin pll : loaded) {
        if (pll.getName().equals(f.getName().replaceAll(".jar", ""))) {
            return null;
        }
    }
    try {
        pl = Bukkit.getPluginManager().loadPlugin(f);
    } catch (UnknownDependencyException | InvalidPluginException | InvalidDescriptionException e) {
        if (e instanceof UnknownDependencyException) {
            sender.sendMessage("[UnlimitedPlugins] Tried to load the jar, " + f.getName()
                    + " but failed because the required dependencies wheren't found.");
        } else if (e instanceof InvalidPluginException) {
            sender.sendMessage("[UnlimitedPlugins] Tried to load the jar, " + f.getName()
                    + " but failed because the jar was invalid.");
        } else if (e instanceof InvalidDescriptionException) {
            sender.sendMessage("[UnlimitedPlugins] Tried to load the jar, " + f.getName()
                    + " but failed because the plugin.yml was invalid.");
        } else {
            sender.sendMessage("[UnlimitedPlugins] Tried to load the jar, " + f.getName()
                    + " but failed because an unknown error occurred.");
        }
        return null;
    }
    if (pl != null) {
        Bukkit.getPluginManager().enablePlugin(pl);
    }
    return pl;
}
项目:economy    文件:SubPluginLoader.java   
public static void valid(SubPlugin sub, PluginDescriptionFile description) throws InvalidPluginException {
    if (Fun.INSTANCE.loaded.contains(sub)) {
        throw new InvalidPluginException("Already loaded by sub-plugin loader");
    } else if (Fun.INSTANCE.map.containsKey(description.getName())) {
        throw new InvalidPluginException("Already loaded by origin");
    }
    for (String depend : description.getDepend()) {
        val load = Fun.INSTANCE.map.get(depend);
        if (load == null || !load.isEnabled()) {
            throw new UnknownDependencyException("Depend plugin " + depend + " not found or enabled");
        }
    }
}
项目:ExilePearl    文件:TestPluginManager.java   
public JavaPlugin loadPlugin(TestPlugin<?> p) throws InvalidPluginException, UnknownDependencyException {
    final JavaPlugin plugin;
    try {
        plugin = (JavaPlugin)p.getPluginClass().newInstance();
    } catch (Exception ex) {
        throw new InvalidPluginException(ex);
    }

       if (plugin != null) {
           plugins.add(plugin);
           lookupNames.put(plugin.getDescription().getName(), plugin);
       }

       return plugin;
}
项目:pploader    文件:PythonPluginLoader.java   
public Plugin loadPlugin(File file, boolean ignoreSoftDependencies)
        throws InvalidPluginException/*, InvalidDescriptionException, UnknownDependencyException*/ {

    if (!file.exists()) {
        throw new InvalidPluginException(new FileNotFoundException(String.format("%s does not exist",
                file.getPath())));
    }

    PluginDataFile data = null;

    if (file.getName().endsWith(".dir") || file.getName().endsWith("_dir")) {
        if (!file.isDirectory())
            throw new InvalidPluginException(new Exception("python directories cannot be normal files! try .py or .py.zip instead."));
        data = new PluginPythonDirectory(file);
    } else if (file.getName().endsWith(".zip") || file.getName().endsWith(".pyp")) {
        if (file.isDirectory())
            throw new InvalidPluginException(new Exception("python zips cannot be directories! try .py.dir instead."));
        data = new PluginPythonZip(file);
    } else {
        throw new InvalidPluginException(new Exception("filename '"+file.getName()+"' does not end in py, dir, zip, or pyp! did you add a regex without altering loadPlugin()?"));
    }

    try {
        return loadPlugin(file, ignoreSoftDependencies, data);
    } finally {
        try {
            data.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
项目:pploader    文件:PluginPythonZip.java   
/**
 * @param file Zipfile we belong to
 * @throws InvalidPluginException thrown if there is an error opening zip
 */
public PluginPythonZip(File file) throws InvalidPluginException {
    filepath = file.getAbsolutePath();  // Store the path of the file
    try {
        this.reload();
    }
    catch (IOException e) {
        throw new InvalidPluginException(e);
    }
}
项目:pexel-platform    文件:BukkitPluginLoader.java   
@Override
public void load(final MinigameDescriptor plugin) {
    try {
        this.plugins.put(plugin, this.internal.loadPlugin(plugin.getJar()));
    } catch (UnknownDependencyException | InvalidPluginException
            | InvalidDescriptionException e) {
        e.printStackTrace();
    }
}
项目:MCPluginDebuggerforMC    文件:Util.java   
public static void loadPlugin(File pluginFile) throws InvalidDescriptionException, InvalidPluginException {
    PluginManager pluginManager = Bukkit.getPluginManager();
    Plugin plugin = pluginManager.loadPlugin(pluginFile);
    plugin.onLoad();
    pluginManager.enablePlugin(plugin);
}
项目:AlphaLibary    文件:Updater.java   
public boolean update() {
    if (!getLatestVersion().equalsIgnoreCase(currentVersion)) {
        String newVersion = getLatestVersion();

        try {
            if (!new File(pluginToUpdate.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).delete())
                Bukkit.getLogger().log(Level.WARNING, "Unable to delete the old version of " + pluginName + " (v." + currentVersion + ")");

            Bukkit.getPluginManager().disablePlugin(pluginToUpdate);

            URL url = new URL(this.updateURL + "/download");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("User-Agent", "SpigetResourceUpdater");
            long completeFileSize = connection.getContentLength();

            BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
            FileOutputStream fos = new FileOutputStream(new File(dataFolder.substring(0, dataFolder.lastIndexOf("/")) + jarName + ".jar"));
            BufferedOutputStream out = new BufferedOutputStream(fos, 1024);

            byte[] data = new byte[1024];
            long downloadedFileSize = 0;
            int i;

            while ((i = in.read(data, 0, 1024)) >= 0) {
                downloadedFileSize += i;

                int progress = (int) ((((double) downloadedFileSize) / ((double) completeFileSize)) * 100);

                System.out.println("Downloading " + pluginName + " to version " + newVersion + " at " + progress + " %");

                out.write(data, 0, i);
            }

            out.close();
            in.close();

            Bukkit.getPluginManager().loadPlugin(new File(dataFolder.substring(0, dataFolder.lastIndexOf("/")) + "/" + jarName + ".jar"));
            Bukkit.getPluginManager().enablePlugin(Bukkit.getPluginManager().getPlugin(pluginName));
            return true;
        } catch (IOException | URISyntaxException | InvalidDescriptionException | InvalidPluginException e) {
            e.printStackTrace();
        }
    }
    return false;
}
项目:VoxelGamesLibv2    文件:LoggedPluginManager.java   
@Override
public Plugin loadPlugin(File file)
        throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
    return delegate.loadPlugin(file);
}
项目:MinigameManager    文件:MinigamePluginManagerWrapper.java   
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
    return pm.loadPlugin(file);
}
项目:economy    文件:SubPluginLoader.java   
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException {
    throw new UnsupportedOperationException("Not supported yet");
}
项目:ExilePearl    文件:TestPluginManager.java   
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
    return null;
}
项目:TagTabAPI    文件:FakePlugin.java   
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException {
    throw new UnsupportedOperationException();
}
项目:NovaGuilds    文件:LoggedPluginManager.java   
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
    return delegate.loadPlugin(file);
}
项目:pploader    文件:PythonPluginLoader.java   
public Plugin loadPlugin(File file) throws InvalidPluginException/*, UnknownDependencyException*/ {
    return loadPlugin(file, false);
}
项目:Almura-API    文件:JavaPluginLoader.java   
public Plugin loadPlugin(File file, boolean ignoreSoftDependencies) throws InvalidPluginException {
    return loadPlugin(file);
}
项目:BedrockAPI    文件:JavaPluginLoader.java   
public Plugin loadPlugin(File file) throws InvalidPluginException {
    return null;
}
项目:BedrockAPI    文件:SimplePluginManager.java   
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException {
    return null;
}
项目:iTag    文件:TagAPI.java   
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException
{
    throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
}
项目:BedrockAPI    文件:PluginLoader.java   
Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException;
项目:BedrockAPI    文件:PluginManager.java   
Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException;