OWHInternals
WARNING: this plugin is very powerful. Be cautious as to who you give permissions to use it.
OWHInternals is a plugin for java scripting at runtime, inside chat/commands. Internals makes use of the apache commons Jexl library, and as such uses Jexl syntax for scripting. For more info on Jexl, visit the Jexl homepage.
Download Logging 1.1.3
in addition, a reference to every user's Player object is created with the variable name $<playername>. References to classes can only call static methods and use static variables. Internals' vault hook contains vault.permissions vault.economy, and vault.chat variables for access to their respective Vault classes.
Installation
Place OWHInternals.jar inside your plugins folder. Download Jexl 2.1.1 and Logging 1.1.3 and place the jars in your server's lib folder. if you don't have a lib folder, create one yourself in the root directory of your server. Internals currently uses Vault for permissions. If Vault is not present on your server, Internals will fall back to checking if the player is an op. Download Jexl 2.1.1Download Logging 1.1.3
How to Use
To define a script in chat / command, you must use the opening bracket "{>" and the closing bracket "<}" (e.g. {>Code Here<}). Everything between these brackets can contain valid Jexl code and will be parsed. Chat/Commands can include as many scripts as they want. The script inside your message / command will be replaced by the value returned from the Jexl script. Thread unsafe code MUST be sent as a command. Failure to do so will result in your server breaking. If you are uncertain whether something is thread-safe, do the smart thing and assume it's not. Internals has references to the following objects in java:Fully qualified class name | Jexl reference | Description |
---|---|---|
java.lang.System.class | System | A reference to the System class. |
java.lang.String.class | String | A reference to the String class. |
info.omgwtfhax.internals.BukkitPlugin | this | A reference to the plugin instance. |
info.omgwtfhax.internals.Vault | vault | A reference to the OWHInternals' vault hook. |
java.util.logging.Logger | logger | A reference to Bukkit.getLogger() for convenience. |
org.apache.commons.lang.StringUtils.class | StringUtils | A reference to the StringUtils class. |
org.bukkit.Bukkit.class | Bukkit | A reference to the Bukkit class. |
org.bukkit.ChatColor.class | ChatColor | A reference to the ChatColor enum. |
org.bukkit.Effect.class | Effect | A reference to the Effect enum. |
org.bukkit.Enchantment.class | Enchantment | A reference to the Enchantment enum. |
org.bukkit.Sound.class | Sound | A reference to the Sound enum. |
org.bukkit.Instrument.class | Instrument | A reference to the Instrument enum. |
org.bukkit.Material.class | Material | A reference to the Material enum. |
org.bukkit.entity.Egg.class | Egg | A reference to the Egg class. [v1.1.0+] |
org.bukkit.entity.Snowball.class | Snowball | A reference to the Snowball class. [v1.1.0+] |
in addition, a reference to every user's Player object is created with the variable name $<playername>. References to classes can only call static methods and use static variables. Internals' vault hook contains vault.permissions vault.economy, and vault.chat variables for access to their respective Vault classes.
Permissions
Internals only uses one permission: owhinternals.administratorDevelopment
Internals is open source. You can find the source here. The source includes some documentation.Todo
- Add script saving
- Executing scripts on events
- More versatility in the way returned values are handled (e.g. sending it back to the user instead of putting it into their chat message)
- Customizable open/close brackets
Thx for the examples, i like the idea of the plugin :p Easy to use, and very powerfull
@crysis992
Sure. Here are a few:
The following examples can all be pasted straight into minecraft chat and will work as described.
Say the hello to the player that has been on your server the longest:
Hello {>Bukkit.getOnlinePlayers().0.getName()<}
The output of your chat message will replace the given code with the returned value.
Force a player to send the message "Hello World":
{>$crysis992.chat("Hello World")<}
This example assumes there is a player currently on your server under the exact name crysis992. Since the method chat() is void, the output would be empty. Empty chat events are cancelled (so you don't end up saying a blank message)
Send a message to every online player:
{>for(player : Bukkit.getOnlinePlayers()){ player.sendMessage("Hello"); }<}
Set your item in hand to the item of another player:
{>$10102.setItemInHand($crysis992.getItemInHand())<}
Similar to the example that forces player chat, this requires player 10102 and player crysis992 to both be online.
Sounds good, could you post any examples?