Fireworks ! WOOHOO
This commit is contained in:
parent
54ec523f6f
commit
1114c3750f
2 changed files with 59 additions and 4 deletions
|
@ -10,7 +10,8 @@
|
||||||
/js arrows.teleport() - makes player teleport to where arrow has landed.
|
/js arrows.teleport() - makes player teleport to where arrow has landed.
|
||||||
/js arrows.flourish() - makes a tree grow where the arrow lands.
|
/js arrows.flourish() - makes a tree grow where the arrow lands.
|
||||||
/js arrows.lightning() - lightning strikes 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
|
All of the above functions can take an optional player object or name as
|
||||||
a parameter. E.g.
|
a parameter. E.g.
|
||||||
|
|
||||||
|
@ -43,7 +44,10 @@ var arrows = arrows || plugin("arrows",{
|
||||||
change player's arrows to strike lightning where they land
|
change player's arrows to strike lightning where they land
|
||||||
*/
|
*/
|
||||||
lightning: function(player){},
|
lightning: function(player){},
|
||||||
|
|
||||||
|
/*
|
||||||
|
launch a firework where the arrow lands
|
||||||
|
*/
|
||||||
explosiveYield: 2.5
|
explosiveYield: 2.5
|
||||||
|
|
||||||
},true);
|
},true);
|
||||||
|
@ -59,7 +63,7 @@ arrows.store.players = arrows.store.players || {};
|
||||||
//
|
//
|
||||||
// setup functions for the arrow types
|
// 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)
|
for (var type in _types)
|
||||||
{
|
{
|
||||||
arrows[type] = (function(n){
|
arrows[type] = (function(n){
|
||||||
|
@ -89,7 +93,7 @@ ready(function()
|
||||||
arrows.store.players[event.player.name] = event.number;
|
arrows.store.players[event.player.name] = event.number;
|
||||||
};
|
};
|
||||||
arrows.sign = signs.menu("Arrow",
|
arrows.sign = signs.menu("Arrow",
|
||||||
["Normal","Explosive","Teleport","Flourish","Lightning"],
|
["Normal","Explosive","Teleport","Flourish","Lightning","Firework"],
|
||||||
_onMenuChoice );
|
_onMenuChoice );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -123,6 +127,10 @@ ready(function()
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
world.strikeLightning(projectile.location);
|
world.strikeLightning(projectile.location);
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
projectile.remove();
|
||||||
|
fireworks.firework(projectile.location);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
47
src/main/javascript/fireworks/fireworks.js
Normal file
47
src/main/javascript/fireworks/fireworks.js
Normal 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());
|
||||||
|
});
|
Reference in a new issue