Executing code input by a player

Discussion in 'Plugin Development' started by cakenggt, May 3, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    cakenggt

    I'm thinking of writing a plugin where if a player right clicks with a book in their hand (the writable kind) then the java code written inside will be executed within a playerInteractEvent method in the plugin. So for example, assuming player = event.getPlayer(); if the book contained the following code:

    Code:
    player.setHealth(20);
    Then the plugin would run this line of code as if it was inside the playerInteractEvent method and fill up the player's health. Does anyone know if it is actually possible to add in java code like this, and if it is, how to do it?

    And yes, I know that this could be a horrible server-crashing idea with the wrong code written in books, but I would like to know if it is possible anyway.
     
  2. Offline

    Komak57

    If you are interested in this, I have already begun work on a much larger project that does things such as that. I suggest you send me a message and message me externally so i can fill you in on the details ^.^
     
  3. Offline

    Kaikz

    You might want to look up an interpreter for JavaScript or Python etc.
     
  4. Offline

    Komak57

    I'm still trying to fix the bugs importing BeanShell, as there seems to be a problem with the ClassPath, but I have a working "crude" interpreter that allows an admin to enable a button or stone pressure plate to execute the script any number of times at a later point. The code can contain variables, adjust variables, match if-then-elseif-else statements, and any number of console commands. Adding BeanShell will multiply the functionality, and allow me to expand past simple buttons and such.
     
Thread Status:
Not open for further replies.

Share This Page