VotifierScripts
VotifierScripts is a plugin that listens for Votifier votes and allows you to run javascript code when a vote is received (allowing for endless possibilities!) This javascript is enhanced with the power of buscript which gives access to many global functions in order to make an easy to use scripting experience. No programming experience is required, but in that case you may find this plugin harder to use than most.
This plugin requires Votifier but already comes prepackaged with buscript.
The latest development builds can always be found at http://ci.onarandombox.com/job/VotifierScripts/
Commands
Currently there's just one command
/vstest <player> [service [address [timestamp]]]
- This command tests the script that is run when a vote is received.
- Permission: votifierscripts.test
- <player> is used to indicate a target for your script. In general, this should probably be someone that is online if you are going to use it.
- The test command will always reload the vote-script.txt file so there is no need to do anything special should you modify the script.
- The other 3 arguments are optional but each one requires using the one before it, so to use timestamp you have to do all 4. These will help you more fully test a vote script.
Scripts
Scripts are text files that contain Javascript code. This may sound scary to people unfamiliar with coding but luckily VotifierScripts provides several easy to use methods for creating basic scripts.
The primary script that is called when Votifier receives a vote is located at plugins/VotifierScripts/vote-script.txt. You will notice this script initially comes with a simple built in sample. Feel free to modify this!
Any script that the primary script runs must be located in plugin/VotifierScripts/scripts and may have any name/file extension you like.
Script Features
- Easy to use global functions including command running, message broadcasting, permission management and more.
- Any string used in these global functions has access to "%target%" which represents the current target of the script. Example: broadcast("Hello, %target%")
- The ability to run another script at a later time with 100% reliability, even if the server crashes!
- Defines the global variable target so more advanced things can be done with the script's target.
- The global variable server is also available which gives direct access to the Bukkit server variable just as if you were working from within a plugin!
Detailed Script Features
Global Functions and Variables
Additional Global Functions and Variables specific to VotifierScripts
Example Scripts
- Simple broadcast/command sample
- vote-script.txt
broadcast("Hey everyone, %target% is a cool guy!") command("op %target%")
- This is a simple script that tells everyone on the server what a cool guy the target (dumptruckman in this case) is and then ops them.
- Timed permission sample
- vote-script.txt
message("%target%", "You have just been given flight in the creative world for 30 minutes!") addPerm("creative", "%target%", "flight.permission") runLater("remove-perm.txt", "30m", "%target%")
- scripts/remove-perm.txt:
message("%target%", "Your flight power has been removed, hope you weren't up there!") removePerm("creative", "%target%", "flight.permission")
- Please note these two scripts require Vault and a Vault compatible permission manager which allows them to work even when the player is not online.
- It is possible to instead use the command() function to run your own permission commands without using Vault.
- Also note "flight.permission" is not a real permission. Your actual flight enabling permission may vary (or not even exist!)
Click Here for more sample scripts
Click Here for script requests
For Developers
Source code: https://github.com/dumptruckman/VotifierScripts
Maven repository: http://repo.onarandombox.com/content/groups/public/
Maven pom information:
<groupId>com.dumptruckman.minecraft</groupId> <artifactId>votifierscripts</artifactId> <version>1.0-SNAPSHOT</version>
You can add your own functionality to the scripts if you so choose. Here's how to hook into VotifierScripts:
Plugin plugin = Bukkit.getPluginManager().getPlugin("VotifierScripts"); if (plugin != null) { Buscript buscript = ((VotifierScripts) plugin).getScriptAPI(); // Do stuff with buscript object, see documentation below }
For more information about the buscript library, visit: http://dev.bukkit.org/server-mods/buscript/
@XeonG8
Oh yeah, actually those are in... Check the changelog for b13 http://dev.bukkit.org/server-mods/votifierscripts/files/6-1-0-snapshot-b15/
You're looking for %service%
Awesome plugin, took care of all the things I had wanted to happen when someone votes with scripts.
Only wondering if its possible to get the site a player had voted at in something like %site%
Can I put on the Buscript aswel ? want to try it using it for some other scripts
@seiterseiter
Please seek support for the plugin causing your issues.
I keep getting this error in the console why.
13:06:09 [WARNING] [Votifier] Unable to decrypt vote record. Make sure that that your public key 13:06:09 [WARNING] [Votifier] matches the one you gave the server list.
javax.crypto.BadPaddingException: Blocktype mismatch: 0 at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:328) at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:272) at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:357) at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:383) at javax.crypto.Cipher.doFinal(Cipher.java:1813) at com.vexsoftware.votifier.crypto.RSA.decrypt(RSA.java:65) at com.vexsoftware.votifier.net.VoteReceiver.run(VoteReceiver.java:130)
@dumptruckman
Checked, I am.
@GoldenWrapper
Make sure you are using Votifier 1.8.
Update: It seems that /vstest <player> works fine, but how can I get it so that PMC works with votifier? Is there some sort of script I have to upload with votifier for it to work? (I tested the connection between the two, they connect fine)
Ok, I am trying to give a user an item when they vote, here is my config for the vote script: broadcast("Thanks for voting, %target%!") command("give %target% 264 5") is there anything else I need to do besides setting up votifier with planetminecraft? Because when I vote, it doesn't say or do anything.
@Circusboy96
I'm not entirely sure what you'd expect to be in a video tutorial... This plugin gives literally unlimited possibility and it's all up to the user on what exactly to do with it.
video tut please!!
@Gunnerrrrr
This is already possible, you'd just have to be creative with your javascript.
Here, added it to the scripts forum: http://dev.bukkit.org/server-mods/votifierscripts/forum/scripts/40231-do-stuff-after-specific-number-of-votes/#p1
i love this plugin this is an amazing plugin helps a lot and i finally fixed my votifier lol i had to portforward 8192 port so now its working and i replaced all my vote listeners to kept flatfilevotelistener and i am using this plugin very nice and when someone votes lol i faked it so it looks like a fake broadcast XD so it legit says [broadcast] Thanks for voting %target%! lol i even added colors so it loooks like a legit broadcast XD anyways nice plugin keep up the great work
@bigscary
Er, I went through and updated every instance of %t to %target% but now I realized I did that everywhere but in the samples that SHIP with the plugin. Nice catch. Was there somewhere else you were talking about?
Oops, I was updating my comment while you were responding. :) Please see my edits.
@bigscary
Ahh, right... This is a plugin. ;)
Edit: and yes, votifier is required.
Hey there DTM, thanks again for a solution I really needed. I'm not 100% sure about the setup - do I drop this into my Votifier's listeners folder, or install it into the plugins folder like I would do for a standard plugin? If the latter, do I also need Votifier itself?
Edit: I was able to figure this out through experimentation and reviewing your code (thanks for publishing it), but I still think a documentation update would be great, to give new users confidence. :)
Also, I noticed that you deprecated %t, but you didn't update your sample scripts to %target%, so trying to play with VotifierScripts without writing a new script results in some odd behavior and an error message.
For anyone tuning in, the answer is that you have to install Votifier, and then install this plugin as a plugin (not in the votifier's listeners folder). There's a default example script included, but for it to work, you need to open it up in your favorite text editor and change all occurrences of %t to %target%.
Thanks again DTM, it's so nice to get Votifier working without having to write a lot of java and compile it. Your decision to include a quick /vstest command is also extremely helpful for testing, since many voting systems only allow one "real" vote per player per day. Great work!
@Tr33x0rs
humm, as long as you use the section symbol § then colors should work... I think I may end up adding the ability to use & as well because it's certainly easier to type.
@Reiby2012
Your second request... Are you asking for the ability to be able to use more than 1 command? just make another line with another command("your command")
@Reiby2012
You can already use colors. use § before the color prefix. etc §c for red.