Fireworks ! WOOHOO

This commit is contained in:
walterhiggins 2013-06-23 19:56:18 +01:00
parent 54ec523f6f
commit 1114c3750f
2 changed files with 59 additions and 4 deletions

View file

@ -10,6 +10,7 @@
/js arrows.teleport() - makes player teleport to where arrow has landed.
/js arrows.flourish() - makes a tree grow where the arrow lands.
/js arrows.lightning() - lightning strikes where the arrow lands.
/js arrows.firework() - A firework launches where the the arrow lands.
All of the above functions can take an optional player object or name as
a parameter. E.g.
@ -44,6 +45,9 @@ var arrows = arrows || plugin("arrows",{
*/
lightning: function(player){},
/*
launch a firework where the arrow lands
*/
explosiveYield: 2.5
},true);
@ -59,7 +63,7 @@ arrows.store.players = arrows.store.players || {};
//
// setup functions for the arrow types
//
var _types = {normal: 0, explosive: 1, teleport: 2, flourish: 3, lightning: 4};
var _types = {normal: 0, explosive: 1, teleport: 2, flourish: 3, lightning: 4, firework: 5};
for (var type in _types)
{
arrows[type] = (function(n){
@ -89,7 +93,7 @@ ready(function()
arrows.store.players[event.player.name] = event.number;
};
arrows.sign = signs.menu("Arrow",
["Normal","Explosive","Teleport","Flourish","Lightning"],
["Normal","Explosive","Teleport","Flourish","Lightning","Firework"],
_onMenuChoice );
/*
@ -123,6 +127,10 @@ ready(function()
projectile.remove();
world.strikeLightning(projectile.location);
break;
case 5:
projectile.remove();
fireworks.firework(projectile.location);
break;
}
}
};

View file

@ -0,0 +1,47 @@
plugin("fireworks", {
/*
create a firework at the given location
*/
firework: function(location){
importPackage(org.bukkit.entity);
importPackage(org.bukkit);
var randInt = function(n){
return Math.floor(Math.random() * n);
};
var getColor = function(i){
var colors = [
Color.AQUA, Color.BLACK, Color.BLUE, Color.FUCHSIA, Color.GRAY,
Color.GREEN, Color.LIME, Color.MAROON, Color.NAVY, Color.OLIVE,
Color.ORANGE, Color.PURPLE, Color.RED, Color.SILVER, Color.TEAL,
Color.WHITE, Color.YELLOW];
return colors[i];
};
var fw = location.world.spawnEntity(location, EntityType.FIREWORK);
var fwm = fw.getFireworkMeta();
var fwTypes = [FireworkEffect.Type.BALL,
FireworkEffect.Type.BALL_LARGE,
FireworkEffect.Type.BURST,
FireworkEffect.Type.CREEPER,
FireworkEffect.Type.STAR];
var type = fwTypes[randInt(5)];
var r1i = randInt(17);
var r2i = randInt(17);
var c1 = getColor(r1i);
var c2 = getColor(r2i);
var effectBuilder = FireworkEffect.builder()
.flicker(true)
.withColor(c1)
.withFade(c2).trail(true);
effectBuilder['with'](type);
var effect = effectBuilder.build();
fwm.addEffect(effect);
fwm.setPower(randInt(2)+1);
fw.setFireworkMeta(fwm);
}
});
Drone.extend('firework',function()
{
fireworks.firework(this.getLocation());
});