Attempt to properly update...

This commit is contained in:
garbagemule
2012-03-01 00:19:17 +01:00
parent 2e76b93837
commit a3fa0539ce
29 changed files with 1972 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Chain Lightning",
aliases = {"chainlightning"}
)
public class ChainLightning implements Ability
{
/**
* How many blocks the chain lightning can spread over.
* Must be greater than 0.
*/
private final int RADIUS = 4;
/**
* How many server ticks between each lightning strike.
* Must be greater than 0.
*/
private final int TICKS = 10;
@Override
public void execute(Arena arena, MABoss boss) {
final LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
if (target == null || !(target instanceof Player))
return;
strikeLightning(arena, (Player) target, new ArrayList<Player>());
}
private void strikeLightning(final Arena arena, final Player p, final List<Player> done) {
arena.scheduleTask(new Runnable() {
public void run() {
if (!arena.isRunning() || !arena.inArena(p))
return;
// Smite the target
arena.getWorld().strikeLightning(p.getLocation());
done.add(p);
// Grab all nearby players
List<Player> nearby = AbilityUtils.getNearbyPlayers(arena, p, RADIUS);
// Remove all that are "done", and return if empty
nearby.removeAll(done);
if (nearby.isEmpty()) return;
// Otherwise, smite the next target!
strikeLightning(arena, nearby.get(0), done);
}
}, TICKS);
}
}
+27
View File
@@ -0,0 +1,27 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Disorient Distant",
aliases = {"disorientdistant"}
)
public class DisorientDistant implements Ability
{
/**
* How far away players must be to be affected by the ability.
*/
private final int RADIUS = 8;
@Override
public void execute(Arena arena, MABoss boss) {
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
p.teleport(loc);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Disorient Nearby",
aliases = {"disorientnearby"}
)
public class DisorientNearby implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), false);
if (target == null) return;
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
p.teleport(loc);
}
}
}
+28
View File
@@ -0,0 +1,28 @@
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Disorient Target",
aliases = {"disorienttarget"}
)
public class DisorientTarget implements Ability
{
/**
* If the boss has no target, should a random player be selected?
*/
private final boolean RANDOM = false;
@Override
public void execute(Arena arena, MABoss boss) {
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
if (target == null) return;
Location loc = target.getLocation();
loc.setYaw(loc.getYaw() + 45 + AbilityUtils.random.nextInt(270));
target.teleport(loc);
}
}
+27
View File
@@ -0,0 +1,27 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Fetch Distant",
aliases = {"fetchdistant"}
)
public class FetchDistant implements Ability
{
/**
* How far away players must be to be affected by the ability.
*/
private final int RADIUS = 8;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
p.teleport(bLoc);
}
}
}
+27
View File
@@ -0,0 +1,27 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Fetch Nearby",
aliases = {"fetchnearby"}
)
public class FetchNearby implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
p.teleport(bLoc);
}
}
}
+25
View File
@@ -0,0 +1,25 @@
import org.bukkit.entity.LivingEntity;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Fetch Target",
aliases = {"fetchtarget"}
)
public class FetchTarget implements Ability
{
/**
* If the boss has no target, should a random player be selected?
*/
private final boolean RANDOM = true;
@Override
public void execute(Arena arena, MABoss boss) {
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
if (target == null) return;
target.teleport(boss.getEntity());
}
}
+28
View File
@@ -0,0 +1,28 @@
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Fire Aura",
aliases = {"fireaura","auraoffire"}
)
public class FireAura implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
/**
* How many ticks the players should be on fire for.
*/
private final int TICKS = 20;
@Override
public void execute(Arena arena, MABoss boss) {
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS))
p.setFireTicks(TICKS);
}
}
+24
View File
@@ -0,0 +1,24 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Flood",
aliases = {"flood"}
)
public class Flood implements Ability
{
@Override
public void execute(Arena arena, MABoss boss) {
Player p = AbilityUtils.getRandomPlayer(arena);
Block block = p.getLocation().getBlock();
if (block.getTypeId() == 0) {
block.setTypeId(8);
arena.addBlock(block);
}
}
}
+26
View File
@@ -0,0 +1,26 @@
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Lightning Aura",
aliases = {"lightningaura","auraoflightning"}
)
public class LightningAura implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
World world = arena.getWorld();
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
world.strikeLightning(p.getLocation());
}
}
}
+59
View File
@@ -0,0 +1,59 @@
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Living Bomb",
aliases = {"livingbomb"}
)
public class LivingBomb implements Ability
{
/**
* How many ticks before the bomb goes off.
*/
private final int FUSE = 60;
/**
* How close players must be to be affected by the bomb.
*/
private final int RADIUS = 3;
/**
* How many ticks players affected by the bomb should burn.
*/
private final int AFTERBURN = 40;
@Override
public void execute(final Arena arena, MABoss boss) {
// Grab the target, or a random player.
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
// We only want players.
if (target == null || !(target instanceof Player))
return;
final Player p = (Player) target;
p.setFireTicks(FUSE + 5);
// Create an explosion after 4 seconds
arena.scheduleTask(new Runnable() {
public void run() {
// If the player died, or if they put out the fire.
if (!arena.isRunning() || !arena.inArena(p) || p.getFireTicks() <= 0) {
return;
}
// Explode!
arena.getWorld().createExplosion(p.getLocation(), 1F);
// And set every nearby player on fire!
for (Player nearby : AbilityUtils.getNearbyPlayers(arena, p, RADIUS)) {
nearby.setFireTicks(AFTERBURN);
}
}
}, FUSE);
}
}
+44
View File
@@ -0,0 +1,44 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Obsidian Bomb",
aliases = {"obsidianbomb"}
)
public class ObsidianBomb implements Ability
{
/**
* How many ticks before the bomb goes off.
*/
private final int FUSE = 80;
@Override
public void execute(final Arena arena, MABoss boss) {
// Grab the target, or a random player.
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
final World world = arena.getWorld();
final Location loc = target.getLocation();
Block b = world.getBlockAt(target.getLocation());
b.setType(Material.OBSIDIAN);
arena.addBlock(b);
arena.scheduleTask(new Runnable() {
public void run() {
if (!arena.isRunning())
return;
world.getBlockAt(loc).breakNaturally();
world.createExplosion(loc, 3F);
}
}, FUSE);
}
}
+35
View File
@@ -0,0 +1,35 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Pull Distant",
aliases = {"pulldistant"}
)
public class PullDistant implements Ability
{
/**
* How far away players must be to be affected by the ability.
*/
private final int RADIUS = 8;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
double a = Math.abs(bLoc.getX() - loc.getX());
double b = Math.abs(bLoc.getZ() - loc.getZ());
double c = Math.sqrt((a*a + b*b));
p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
}
}
}
+35
View File
@@ -0,0 +1,35 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Pull Nearby",
aliases = {"pullnearby"}
)
public class PullNearby implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
double a = Math.abs(bLoc.getX() - loc.getX());
double b = Math.abs(bLoc.getZ() - loc.getZ());
double c = Math.sqrt((a*a + b*b));
p.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
}
}
}
+35
View File
@@ -0,0 +1,35 @@
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Pull Target",
aliases = {"pulltarget"}
)
public class PullTarget implements Ability
{
/**
* If the boss has no target, should a random player be selected?
*/
private final boolean RANDOM = false;
@Override
public void execute(Arena arena, MABoss boss) {
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
if (target == null) return;
Location loc = target.getLocation();
Location bLoc = boss.getEntity().getLocation();
Vector v = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
double a = Math.abs(bLoc.getX() - loc.getX());
double b = Math.abs(bLoc.getZ() - loc.getZ());
double c = Math.sqrt((a*a + b*b));
target.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
}
}
+73
View File
@@ -0,0 +1,73 @@
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
/**
* DISCLAIMER: The Ability source code is provided as-is, and the creator(s) of
* MobArena WILL NOT be held responsible for any damage that may
* result from altering the files.
*
* WARNING: Unless you know exactly what you are doing, i.e. you have a lot
* of experience with Java and Bukkit, you should never change any
* other values than those of the variables in CAPITAL LETTERS.
*
*
* Root Target
* Freezes the boss' target in place for ~3 seconds (default), by warping the
* player to the same spot [ITERATIONS] times, with [TICKS] server ticks
* between each iteration.
*
* @author garbagemule
*/
@AbilityInfo(
name = "Root Target",
aliases = {"roottarget", "freezetarget"}
)
public class RootTarget implements Ability
{
/**
* How many times the player will be warped back to his original position.
* Must be greater than 0.
*/
private final int ITERATIONS = 5;
/**
* How many server ticks between each iteration of
* Must be greater than 0.
*/
private final int TICKS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
final LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
if (target == null || !(target instanceof Player))
return;
Player p = (Player) target;
Location loc = p.getLocation();
rootTarget(arena, p, loc, ITERATIONS);
}
private void rootTarget(final Arena arena, final Player p, final Location loc, final int counter) {
// If the counter is 0, we're done.
if (counter <= 0) {
return;
}
arena.scheduleTask(new Runnable() {
public void run() {
if (!arena.isRunning() || !arena.inArena(p)) {
return;
}
p.teleport(loc);
rootTarget(arena, p, loc, counter - 1);
}
}, TICKS);
}
}
+18
View File
@@ -0,0 +1,18 @@
import org.bukkit.entity.Arrow;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Shoot Arrow",
aliases = {"arrow","arrows"}
)
public class ShootArrow implements Ability
{
@Override
public void execute(Arena arena, MABoss boss) {
//boss.getEntity().launchProjectile(Arrow.class);
boss.getEntity().shootArrow();
}
}
+18
View File
@@ -0,0 +1,18 @@
import org.bukkit.entity.Fireball;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Shoot Fireball",
aliases = {"fireball","fireballs"}
)
public class ShootFireball implements Ability
{
@Override
public void execute(Arena arena, MABoss boss) {
//boss.getEntity().launchProjectile(Fireball.class);
boss.getEntity().throwEgg();
}
}
+41
View File
@@ -0,0 +1,41 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Shuffle Positions",
aliases = {"shuffle","shufflepositions"}
)
public class ShufflePositions implements Ability
{
@Override
public void execute(Arena arena, MABoss boss) {
// Grab the players and add the boss
List<LivingEntity> entities = new ArrayList<LivingEntity>(arena.getPlayersInArena());
entities.add(boss.getEntity());
// Grab the locations
List<Location> locations = new LinkedList<Location>();
for (LivingEntity e : entities) {
locations.add(e.getLocation());
}
// Shuffle the entities list.
Collections.shuffle(entities);
/* The entities are shuffled, but the locations are not, so if
* we remove the first element of each list, chances are they
* will not match, i.e. shuffle achieved! */
while (!entities.isEmpty() && !locations.isEmpty()) {
entities.remove(0).teleport(locations.remove(0));
}
}
}
+30
View File
@@ -0,0 +1,30 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Throw Distant",
aliases = {"throwdistant"}
)
public class ThrowDistant implements Ability
{
/**
* How far away players must be to be affected by the ability.
*/
private final int RADIUS = 8;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getDistantPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
p.setVelocity(v.normalize().setY(0.8));
}
}
}
+30
View File
@@ -0,0 +1,30 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Throw Nearby",
aliases = {"thrownearby"}
)
public class ThrowNearby implements Ability
{
/**
* How close players must be to be affected by the ability.
*/
private final int RADIUS = 5;
@Override
public void execute(Arena arena, MABoss boss) {
Location bLoc = boss.getEntity().getLocation();
for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
Location loc = p.getLocation();
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
p.setVelocity(v.normalize().setY(0.8));
}
}
}
+31
View File
@@ -0,0 +1,31 @@
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Throw Target",
aliases = {"throwtarget"}
)
public class ThrowTarget implements Ability
{
/**
* If the boss has no target, should a random player be selected?
*/
private final boolean RANDOM = false;
@Override
public void execute(Arena arena, MABoss boss) {
LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
if (target == null) return;
Location bLoc = boss.getEntity().getLocation();
Location loc = target.getLocation();
Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
target.setVelocity(v.normalize().setY(0.8));
}
}
+18
View File
@@ -0,0 +1,18 @@
import org.bukkit.entity.Player;
import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.waves.MABoss;
import com.garbagemule.MobArena.waves.ability.*;
@AbilityInfo(
name = "Warp",
aliases = {"warp","warptoplayer"}
)
public class WarpToPlayer implements Ability
{
@Override
public void execute(Arena arena, MABoss boss) {
Player p = AbilityUtils.getRandomPlayer(arena);
boss.getEntity().teleport(p);
}
}