[INACTIVE][DEV] ScriptInjector v0.15 - Execute java code in on the fly [617]

Discussion in 'Inactive/Unsupported Plugins' started by Edward Hand, Mar 31, 2011.

  1. Offline

    Edward Hand

    ScriptInjector
    version: v0.15
    There are many times in plugin development and testing when you just want to run a quick function or lookup a variable and don't want to have to write/rewrite a plugin to do it. This plugin allows you to do just that easily and quickly (and a lot more besides).
    The Basics
    When this plugin loads, a new window will pop up alongside the server console. This is the script injection window.
    In this window you can type in any java code, and when you press [return] it will be interpreted and run.
    Functions and variables can be defined and called within the interpreter and will be stored in memory until the plugin is disabled.
    Anything you can do under normal circumstances within a plugin can be done inside the interpreter.
    In order that you be able to call functions within the server, one variable comes pre-defined for you and that is plugin.

    Plugin refers to the running instance of the ScriptInjector plugin. Use it as you would a reference to your main JavaPlugin class in your own plugins.

    Example (open)
    //Notch has logged in! Quick let's set him on fire!
    plugin.getServer().getPlayer("Notch").setFireTicks(1000);

    [I][B][FONT=arial black][FONT=trebuchet ms]Applications[/FONT][/FONT][/B][/I]
    • Exploration - Answer questions like "I wonder what that function does" and "what happens if I change this variable?" Useful for investigating the obfuscated server source at the very least.
    • Testing - Got a quick idea you want to test? Try it out.
    • Debugging - Look up the value of any variable (even private ones) just by typing a reference to it in the interpreter or call any function. Debug without changing a single line of code.
    • Fun - Make spur-of-the-moment temporary 'plugins' on the fly, for fun, on your server.
    More Features

    Script files + Predefined Functions (open)
    The file "ScriptInjector/startup.java" contains code that is run when the plugin is enabled. In there I have defined a number of functions that may be useful. You may add to this file yourself.

    You can also create your own files of java code and load them in at any time with:
    loadScript("filename.java");
    (defined in startup.java)
    Command Access (open)
    Java code can also be run from chat using:
    /eval [put the code you want to run here]
    Anything returned by the code will be posted back to you in chat. Functions/variables defined in the Interpreter Window can be called in chat and visa versa.

    commandAccess.eval permission is required.

    Multi threading (open)
    By default, all code is run on the minecraft main thread. If you want code to be executed in a thread on its own (eg for monitoring variables at regular intervals) you can turn on threading with:

    setThreading(true);

    (which is defined in startup.java). All subsequent code execution will be run on its own thread.

    Integrate with your plugins easily (open)
    The plugin variable comes predefined to point to the ScriptInjector plugin but can easily be changed to point at your own plugin with:
    setPlugin("yourPluginName");
    (defined in startup.java)

    Or you can build the link into your plugin code by calling the setPlugin(Plugin p) function in the ScriptInjector main class.

    Download now

    Copy everything in the zip file to your plugins directory.
    Feature Summary
    • Execute java code on the fly either from a console or through chat
    Changelog

    v0.1
    • Plugin released
    v0.15
    • Plugin will now allow /eval to work even if the script window cant initialise (eg when running on command-line-only servers).
     
    DPOH-VAR, wizjany, matter123 and 2 others like this.
  2. Offline

    Plague

  3. Offline

    Edward Hand

    I've been trying to fix the formatting for the past 15 minutes now. Every time I almost get it right I delete one light break or something and all the spoiler blocks duplicate for no reason.

    What did I miss anyway?
     
  4. Offline

    Plague

    If you get problems edit in the source code.

    Violet color, italics, first two lines should be name \n version: vx.x etc.
     
  5. Offline

    Edward Hand

    What's wrong with colour+italics? Guidelines doesn't say anything about them. Other plugin threads get to use colours :(
     
  6. Offline

    Plague

    You know, new moderator, blindly adhering to the rules :) There is a template so I use it to make all posts look the same (which is wanted since Fill will do the same).

    I know that some older plugins use various formatting, but I don't have the will to go through all released plugins (:confused:), so I only try to make all those I move make look like the template.
     
  7. Offline

    MrChick

    Holy cow that's exactly what I needed. Thank you so much!
     
  8. Offline

    aPunch

    Wow, this is awesome! I always hate finding small problems when testing my plugins in-game, and this will let me see what happens when I try to fix them. Thanks, a lot!
     
  9. Offline

    fullwall

    Must have taken a lot of work Edward - very well done :).
     
  10. Offline

    MrChick

    That's on version:
    13:43:40 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-572-g95523e4-b568jnks (MC: 1.3)

    All I did was install the plugin (put everything from the zip into the plugins-folder).

    Any idea on what's wrong?

    Edit: just updated to 613, same error... do I need 617?

    Edit #2: Despite the error, everything seems to be working.
     
  11. Offline

    Edward Hand

    Nothing's wrong! If it says STARTUP SUCCESSFUL then everything is fine.

    The big lump of text is the startup script in /ScriptInjector/startup.java being run.
     
  12. Offline

    MrChick

    Yeah, but there's an error in there:
     
  13. Offline

    Edward Hand

    Ah yes. I'm sure that method existed yesterday....

    Not important though. Don't worry ;D
     
  14. Offline

    MrChick

    Alright :D
     
  15. Offline

    retsrif

    Hmm... Script injecting ScriptInjector... Has anyone tried that? :p Also, this will be really useful thanks! :D
     
  16. Offline

    Peva

    Wait so how much better does the server run in multithread?
     
  17. Offline

    weasel5i2

    Awesomely exploitable! But terribly useful! Two thumbs up :D

    I wonder if you can call classes like Java.io.etc.. and read arbitrary filesystem files using this...
     
  18. Offline

    Slayer9x9

    OOOOOOO fun fun!
    This will be much useful.
     
  19. Code:
    2011-04-02 16:47:41 [INFO] Script Injection Enabled
    2011-04-02 16:47:41 [SEVERE]
    No X11 DISPLAY variable was set, but this program performed an operation which requires it. loading ScriptInjector v0.1 (Is it up to date?)
    java.awt.HeadlessException:
    No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.awt.GraphicsEnvironment.checkHeadless(Unknown Source)
        at java.awt.Window.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at com.edwardhand.scriptinjector.ScriptWindow.<init>(ScriptWindow.java:21)
        at com.edwardhand.scriptinjector.ScriptInjector.onEnable(ScriptInjector.java:76)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:118)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:514)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:216)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:94)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:72)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:215)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:202)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:142)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:257)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    I'm getting this error D:
    And when I try to use eval this happens:

    Code:
    2011-04-02 16:48:12 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'eval' in plugin ScriptInjector v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:80)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:233)
        at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:594)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:557)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:551)
        at net.minecraft.server.Packet3Chat.a(SourceFile:24)
        at net.minecraft.server.NetworkManager.a(NetworkManager.java:198)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:72)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:368)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    Caused by: java.lang.NullPointerException
        at com.edwardhand.scriptinjector.ScriptInjector.onCommand(ScriptInjector.java:133)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
        ... 12 more
     
  20. Offline

    Edward Hand

    Eval won't work because the plugin isn't enabling properly.

    My guess would be that you trying to run this on a linux server with no desktop interface (only command line). Is this correct?

    If not, then something very strange is going on with your system...
     
  21. Yes that is correct. Does that mean I can't use this without a desktop interface? :C
     
  22. Offline

    Edward Hand

    Updated the plugin for you. The interpreter is now independent of the pop-up window so eval should now work for you at least.
     
    PurpleMadness likes this.
  23. Thanks. ^_^

    EDIT: It works swell so far, but there's just one problem. I can't seem to use the plugin variable. Is this a side effect?
     
  24. Offline

    Edward Hand

    My stupid error. Sorry.
    Re-download 1.5 now and it should be fixed.
     
  25. Offline

    SycoPrime

    Awesome.
     
  26. Offline

    exemplar

    This code looks very similar to my old single player injector.
     
  27. Offline

    Plague

    @Edward Hand update the thread to latest RB please
     
  28. Offline

    MonsieurApple

    Considered inactive.
     
  29. Offline

    RawCode

    A bit of necroposting...

    do anyone have jar by hand, current link is dead?
     
  30. RawCode lel I want to see the src too :>
     

Share This Page