Created
September 28, 2014 09:34
-
-
Save SpaceManiac/abc69914f18b572fe8cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- | |
# name: ParticleTest | |
# version: 1.0 | |
# author: SpaceManiac | |
# commands: | |
# part: | |
# description: Particle testing | |
# --- | |
import quick | |
from org.bukkit import Particle, Material | |
from org.bukkit.material import MaterialData | |
from org.bukkit.scheduler import BukkitRunnable | |
class DoThings(BukkitRunnable): | |
def __init__(self, player, particle): | |
self.player = player | |
self.particle = particle | |
def run(self): | |
spread, speed, count = 0.3, 0.2, 20 | |
self.player.sendMessage("Showing particle: %s with spread %s, speed %s, count %s" % (self.particle, spread, speed, count)) | |
self.player.showParticle(self.player.location.add(0, 3, 0), self.particle, spread, spread, spread, speed, 20) | |
@quick.command('part') | |
def onCommand(sender, command, label, args): | |
if len(args) < 1: | |
return False | |
subcmd = args[0] | |
if subcmd == "list": | |
vals = Particle.values() | |
sender.sendMessage("Available particles (%s): %s" % (len(vals), ', '.join(str(v) for v in vals))) | |
elif subcmd == "all": | |
for i, part in enumerate(Particle.values()): | |
if not part.usesMaterial(): | |
DoThings(sender, part).runTaskLater(quick.plugin, i * 40) | |
else: | |
try: | |
particle = Particle.valueOf(subcmd) | |
except: | |
sender.sendMessage("No such particle %s, try \"list\"" % subcmd) | |
return True | |
data = None | |
if particle.usesMaterial(): | |
if len(args) < 2: | |
sender.sendMessage("Must provide material") | |
return True | |
if len(args) == 2: | |
data = MaterialData(Material.matchMaterial(args[1])) | |
else: | |
data = MaterialData(Material.matchMaterial(args[1]), int(args[2])) | |
spread, speed, count = 0.3, 0.2, 20 | |
sender.sendMessage("Showing particle: %s with spread %s, speed %s, count %s" % (particle, spread, speed, count)) | |
sender.showParticle(sender.location.add(0, 3, 0), particle, data, spread, spread, spread, speed, 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ohhh shiny. Is this for MiniPython?