print arrays correctly
This commit is contained in:
parent
cd57974db3
commit
fa58ba7322
1 changed files with 10 additions and 2 deletions
|
@ -7,6 +7,8 @@ import java.io.IOException;
|
||||||
import javax.script.*;
|
import javax.script.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
|
@ -90,8 +92,14 @@ public class ScriptCraftPlugin extends JavaPlugin
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
Object result = this.engine.eval(javascriptCode);
|
Object result = this.engine.eval(javascriptCode);
|
||||||
if (result != null)
|
if (result != null){
|
||||||
|
if (result instanceof java.util.Collection){
|
||||||
|
java.util.Collection collection = (java.util.Collection)result;
|
||||||
|
sender.sendMessage(Arrays.toString(collection.toArray()));
|
||||||
|
}else{
|
||||||
sender.sendMessage(result.toString());
|
sender.sendMessage(result.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
sender.sendMessage(e.getMessage());
|
sender.sendMessage(e.getMessage());
|
||||||
|
|
Reference in a new issue