Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

More flexible script loading/unloading from Java #371

Open
jarcode-foss opened this issue May 23, 2015 · 4 comments
Open

More flexible script loading/unloading from Java #371

jarcode-foss opened this issue May 23, 2015 · 4 comments

Comments

@jarcode-foss
Copy link

(I don't write skript myself, I'm simply writing a plugin hook to support skript creation)

Using java, there's currently no real nice way to call script loading/unloading, other than using ScriptLoader.loadScripts(File folder) and unloadScripts(...) from the same class. There's a few issues with this:

  • This restricts loading and unloading from a folder, where single files may be necessary
  • There is no way to load a script from memory (requiring file I/O for every script change, sort of silly for what I'm trying to do)
    • The lack of abstraction makes me feel like these methods could break on a plugin update. Why not store methods meant to be used externally in an interface, that you can guarantee support for in later versions?

I have resorted to using reflection to call script loading and unloading on single files, but I feel like this is a very poor solution that may break given any skript developers choose to change anything in ScriptLoader.

@Mirreski
Copy link
Contributor

There's currently no one working on the current version of Skript(As far as I know).

Well Destroyer is making a new Skript, developing it from scratch. So the code will change completely. But it will take a long while before that's out I think.

You can load or unload single files without resorting to reflection. Since you said you were not using Skript, I can say that there's a command /skript (reload|enable|disable) <script>.

https://github.com/Njol/Skript/blob/master/src/main/java/ch/njol/skript/SkriptCommand.java
Check out the getScriptFromArgs method and the onCommand.

ScriptLoader.loadScripts(File folder) is restricted to folders yes.
But there's also ScriptLoader.loadScripts(final File[] files) which is for specific scripts.

Your other statements I agree with.

@jarcode-foss
Copy link
Author

Thanks for showing me those other methods. I don't know how I missed them.

I'm happy to help out on that other version of skript, there is a lot of stuff in here that warrants a re-write. Is there a link to the repository?

@Mirreski
Copy link
Contributor

No problem:P

The repository is here: https://github.com/w00tmast3r/Skript

Check out the branches(parser and variables) for code since the master branch doesn't have any code.

I don't know how much he has done other than the code there(Last updated 16 days ago) or if he wants any help.

A working version will perhaps/probably take a while.

@jarcode-foss
Copy link
Author

Oh, that looks very... primitive. I would have to wait until he has the parser for skript done, at least. I don't think jumping in and making pull requests when he's in the middle of writing a parser would be the best idea.

I'm looking at getting Skript integration into my Consoles project/plugin, it has a text editor that I think would be nice to support writing with Skript in addition to the current Lua programs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants