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/

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of ataranlen ataranlen Feb 03, 2015 at 05:58 UTC - 0 likes

    Edit: Looks like I can fetch it with this call:

      var offlinePlayer = plugin.getServer().getOfflinePlayer(username)
      var uuid = offlinePlayer.getUniqueId()
    

    I'm trying to create a script to fetch the UUID of a player to add it to a database along with the username.

    I'm having some issues with XMLHttpRequest, particularly with "XMLHttpRequest" is not defined.

    I'm running version 1.1 from April.

    Is there a better way to do this?

    function getUUID() {
      var xmlhttp = new XMLHttpRequest();
      var url = "https://api.mojang.com/users/profiles/minecraft/" + username;
    
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              var myArr = JSON.parse(xmlhttp.responseText);
              myFunction(myArr);
          }
      }
      xmlhttp.open("GET", url, true);
      xmlhttp.send();
    }
    
    Last edited Feb 03, 2015 by ataranlen

    Come play with us: MineTexas.com

  • Avatar of EpicMinerMan321 EpicMinerMan321 Dec 28, 2014 at 20:45 UTC - 0 likes

    @Maffinator: Go

    Make sure you have vault installed and working.Its telling you it isn't installed

  • Avatar of LordKainzo LordKainzo Apr 21, 2014 at 20:12 UTC - 0 likes

    @ViscousSummer88: Go

    you could just use the GAListener - it has support for counting votes in SQL now.

  • Avatar of Maffinator Maffinator Apr 18, 2014 at 12:25 UTC - 0 likes

    Error with addMoney, I'm running Vault and it says:

    "Error running script: Wrapped java.lang.IllegalStateException: Vault must be installed to use addMoney(player, money)! (plugins/VotifierScripts/vote-script.txt#4)"

    Any idea what's going on?

  • Avatar of ViscousSummer88 ViscousSummer88 Mar 06, 2014 at 17:31 UTC - 0 likes

    @dumptruckman: Go

    Interesting, because I would have guessed using the latest DEV Build you have pushed back in April of last year would have worked also, however it did not. The latest version located on this page (1.1) also does not load up. So actually it does not work, still to this point, using either Craftbukkit or Spigot.

    Sadly, I'm at a loss at what the issue is, same error upon start-up.

    http://epiccrafts.co.uk/secure/EpicCrafts%20Banner.gif
    Personal Website: http://viscoussummer88.co.uk

  • Avatar of YiveMe YiveMe Feb 16, 2014 at 15:39 UTC - 0 likes

    Not sure if this is caused by Pex or Votifierscripts. http://pastebin.com/raw.php?i=jDYrdcHZ

    Last edited Feb 18, 2014 by YiveMe

    Large Minecraft API Site: http://mcapi.ca

  • Avatar of dumptruckman dumptruckman Feb 11, 2014 at 17:30 UTC - 0 likes

    @ViscousSummer88: Go

    It works fine if you, you know, use the latest version that says it fixes a breaking issue.

  • Avatar of Maffinator Maffinator Feb 11, 2014 at 16:20 UTC - 0 likes

    @ViscousSummer88: Go

    You're running Spigot. It works fine with bukkit.

  • Avatar of ViscousSummer88 ViscousSummer88 Jan 29, 2014 at 21:39 UTC - 0 likes

    @luridftw32: Go

    Interesting, what CB build are you running?

  • Avatar of luridftw32 luridftw32 Jan 28, 2014 at 17:19 UTC - 0 likes

    @ViscousSummer88: Go

    Works fine for me.

    LuridCraft!

Facts

Date created
Jul 23, 2012
Categories
Last update
Aug 22, 2012
Development stage
Release
Language
  • enUS
License
Mozilla Public License 2.0
Curse link
VotifierScripts
Downloads
17,658
Recent files

Authors