-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
――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.
--macOS mojave or later
--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 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);
}
}
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