[JAVA] Vuze plugin to write and enjoy

Introduction

-When I looked at BT client Vuze javadoc, it looked like a cool structure. ――I want to make a plug-in --Sort the priorities in descending order of seeder

Caution

――The official Plugin Description Site is very old, so if you are inspired, you will be on the thorny path. ――I'm just writing in a tutorial style until I get tired of it, but I haven't written a full tutorial on how to take steps. You can't enjoy it unless you have enough experience to read the description and drawing of the reference site according to your own environment.

Assumed environment

--macOS mojave or later

Environmental setup

--Procedure - File > New > Project ... - Java - Project SDK: java version 12.0.1 - name: DemoPlugin - File > New > Directory - lib/ - jni dependency here - libOSXAccess.jnilib - libOSXAccess_10.5.jnilib - vuze dependency here - Vuze_5760.jar - Vuze_5760_pluginapi.jar - swt dependency here - swt.jar - src/config/ - File > New > File - plugin.properties - Open Module Settings.. > Project Settings > Modules > [DemoPlugin] - Sources - lib ... mark as Excluded - src ... mark as Sources - src/config ... mark as Excluded - Paths - (*) Use module compile output path - Output path: /Users/foo/src/github.com/foo/DemoPlugin/src/config/plugins/DemoPlugin - Run > Edit Configuration ... - Add Application - Name: Plugin Debug - Main class: org.gudy.azureus2.ui.swt.Main - VM options: -Dazureus.config.path="/Users/foo/src/github.com/foo/DemoPlugin/src/config/" -Djava.library.path="/Users/foo/src/github.com/foo/DemoPlugin/lib/" -XstartOnFirstThread

src/org/azureus/plugins/demo/Core.java


package org.azureus.plugins.demo;

import org.gudy.azureus2.plugins.PluginException;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.UnloadablePlugin;
import org.gudy.azureus2.plugins.logging.LoggerChannel;

public class Core implements UnloadablePlugin {
    @Override
    public void unload() throws PluginException {
   
    }

    @Override
    public void initialize(PluginInterface pluginInterface) throws PluginException {
        LoggerChannel channel = pluginInterface.getLogger().getChannel("demo");

        //When executed, the following is added to the alert message at the bottom right of the UI.
        channel.logAlert(LoggerChannel.LT_INFORMATION, "Hello, \n World!");
    }
}

src/plugin.properties


plugin.class=org.azureus.plugins.demo.Core
plugin.name=DemoPlugin
plugin.id=demoplugin
plugin.version=0.0.1

I want to sort the priority in descending order of seeder

I was able to confirm that the priority was switched normally when debug was started.

src/org/azureus/plugins/demo/Core.java


package org.azureus.plugins.demo;

import org.gudy.azureus2.plugins.PluginException;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.UnloadablePlugin;
import org.gudy.azureus2.plugins.download.Download;
import org.gudy.azureus2.plugins.logging.LoggerChannel;

import java.util.*;

public class Core implements UnloadablePlugin {

    private LoggerChannel channel;
    private PluginInterface pluginInterface;

    @Override
    public void unload() throws PluginException {}

    private void alert(String s){
        this.channel.logAlert(LoggerChannel.LT_INFORMATION, s);
    }

    @Override
    public void initialize(PluginInterface pluginInterface) throws PluginException {
        this.channel = pluginInterface.getLogger().getChannel("demo");
        this.pluginInterface = pluginInterface;

        timer();
    }

    private void timer(){
        TimerTask task = new TimerTask() {

            Download[] downloads;
            List<Download> downloadPriorites;

            public void run() {
                downloads = pluginInterface.getDownloadManager().getDownloads();
                downloadPriorites = new ArrayList<>();

                for(Download dl : downloads) {
                    if(dl.getLastAnnounceResult().getSeedCount() == 0){
                        continue;
                    }
                    downloadPriorites.add(dl);
                }

                Collections.sort(downloadPriorites, new SeederComparator());

                for(int i=0;i<downloadPriorites.size();i++){
                    Download dl = reset.get(i);

                    int pri = i+1;
                    dl.setPosition(pri);
                }
            }
        };

        Timer timer = new Timer();
        timer.scheduleAtFixedRate(task, 1000, 5000);
    }

}

class SeederComparator implements Comparator<Download> {

    public int compare(Download a, Download b) {
        int no1 = a.getLastAnnounceResult().getSeedCount();
        int no2 = b.getLastAnnounceResult().getSeedCount();

        // desc by seed count
        return Integer.compare(no2, no1);
    }
}

package

However, when I try using Install Plugins from Vuze's plugin manager, I get the following error.

DemoPlugin'Failed to verify: Signature doesn't match data

However, the documentation does not prevent the installation of your own plugin without the * official team signature. * Because there is, what is the cause ...?

For your own plugins, Azureus will warn you that it is not an official plugin - you need someone from the Azureus team to sign your plugin to stop this warning from appearing. The fact that the plugin hasn't been signed won't actually stop you from being able to install it.

Recommended Posts

Vuze plugin to write and enjoy
[Java] How to output and write files!
How to write and explain Dockerfile, docker-compose
JDBC promises and examples of how to write
How to write Rails
[Java] Types of comments and how to write them
To implement, write the test and then code the process
How to write dockerfile
How to write docker-compose
How to write Mockito
How to write migrationfile
How to write and notes when migrating from VB to JAVA
When you want to explicitly write OR or AND with ransack
Write DiscordBot to Spreadsheets Write in Ruby and run with Docker
Read and write like java.nio
How to write good code
Gradle to touch and remember
Bit Tetris (how to write)
How to write java comments
[Refactoring] How to write routing
Great poor (how to write)
[Note] How to write Dockerfile/docker-compose.yml
How to write Junit 5 organized
How to write Rails validation
How to write Rails seed
To write a user-oriented program (1)
[Ruby] How to write blocks
How to write Rails routing
I want to be able to think and write regular expressions myself. ..
Basics of Java development ~ How to write programs (variables and types) ~
Offline real-time how to write F03 ruby and C implementation example
Steps to build and install an existing Eclipse plug-in project yourself
Sample to read and write LibreOffice Calc fods file in JRuby 2021
[Reading impression] "How to learn Rails, how to write a book, and how to teach"
Sample to read and write LibreOffice Calc fods file in Java 2021