Skip to content
This repository has been archived by the owner on Jul 1, 2019. It is now read-only.

Commit

Permalink
Fix makeplugin's bug and improve compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
fengberd committed Jul 26, 2016
1 parent 064a3f2 commit 3f72384
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,20 @@ The first devtools plugin for Nukkit!
* If you don't have JDK,just download tools.jar from [Here](https://www.dropbox.com/s/vjvcebljpk6qlmj/tools.jar?dl=0) and put it into FDevTools folder then it works well too.
* You can pack the plugin into jar and relese it easyily.

## Attention
Your source plugin should follow this format:

1. Make a dir in plugins folder(e.g. MyPlugin_src).
2. Put your plugins yml into it.
3. Make a "src" dir into it.
4. Put your source into "src" dir.

Now your plugin should looks like this:
>MyPlugin_src
├plugin.yml
└src
   └moe/berd/Test
       └Main.java

# Commands
* makeplugin <PluginName> - Compress the plugin into jar format(It must loaded by FDevTools).
* `makeplugin <PluginName>` - Compress the plugin into jar format(It must loaded by FDevTools).
Binary file modified moe/berd/FDevTools/Main.class
Binary file not shown.
13 changes: 9 additions & 4 deletions moe/berd/FDevTools/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class Main extends PluginBase
private static Main obj=null;

private JavaCompiler compiler=null;
private SourcePluginLoader loader=null;

public static Main getInstance()
{
Expand Down Expand Up @@ -62,13 +61,14 @@ public boolean onCommand(CommandSender sender,Command command,String label,Strin
{
sender.sendMessage("[FDevTools] "+TextFormat.RED+"Plugin not exists,check your plugin name");
}
else if(plugin.getPluginLoader()!=this.loader)
else if(plugin.getPluginLoader().getClass()!=SourcePluginLoader.class)
{
sender.sendMessage("[FDevTools] "+TextFormat.RED+"Plugin isn't loaded by FDevTools");
}
else
{
File dir=this.loader.getPluginPath(plugin);
SourcePluginLoader loader=(SourcePluginLoader)plugin.getPluginLoader();
File dir=loader.getPluginPath(plugin);
if(dir==null)
{
sender.sendMessage("[FDevTools] "+TextFormat.RED+"Can't find plugin source path!");
Expand All @@ -80,7 +80,7 @@ else if(plugin.getPluginLoader()!=this.loader)
if(args.length>=2 && args[1].toLowerCase().equals("true"))
{
sender.sendMessage("[FDevTools] "+TextFormat.AQUA+"Re-compiling source...");
if(!this.loader.compilePlugin(dir,class_file))
if(!loader.compilePlugin(dir,class_file))
{
sender.sendMessage("[FDevTools] "+TextFormat.RED+"Can't compile plugin source!");
break;
Expand Down Expand Up @@ -168,6 +168,11 @@ else if(plugin.getPluginLoader()!=this.loader)
return true;
}

public JavaCompiler getCompiler()
{
return this.compiler;
}

@SuppressWarnings("unchecked")
public JavaCompiler checkCompiler()
{
Expand Down
Binary file modified moe/berd/FDevTools/SourcePluginLoader.class
Binary file not shown.
2 changes: 1 addition & 1 deletion moe/berd/FDevTools/SourcePluginLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SourcePluginLoader(Server server)
{
this.server=server;
this.plugin=Main.getInstance();
this.compiler=Main.getInstance().checkCompiler();
this.compiler=this.plugin.getCompiler();
this.filemanager=this.compiler.getStandardFileManager(null,null,null);
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: FDevTools
main: moe.berd.FDevTools.Main
version: "1.0.0"
version: "1.0.1"
api: ["1.0.0"]
load: STARTUP
author: FENGberd
Expand Down

0 comments on commit 3f72384

Please sign in to comment.