Special Abilities - OresomeCraft/MapsPlugin GitHub Wiki
This page has the snippets for all the special effects currently used on our maps! Feel free to copy them into your own maps!
Grappling Hook
The grappling hook found in Casa de Perro.
@EventHandler
public void fishing(org.bukkit.event.player.PlayerFishEvent event) {
Material mat = event.getPlayer().getItemInHand().getType();
if (event.getPlayer().getLocation().getWorld().getName().equals(name) && mat == Material.FISHING_ROD
&& event.getState() == org.bukkit.event.player.PlayerFishEvent.State.IN_GROUND)
event.getPlayer().launchProjectile(org.bukkit.entity.Snowball.class);
}
@EventHandler
public void grapple(org.bukkit.event.entity.ProjectileHitEvent event) {
org.bukkit.entity.Entity proj = event.getEntity();
Location hit = proj.getLocation();
if (hit.getWorld().getName().equals(name) && proj instanceof org.bukkit.entity.Snowball) {
org.bukkit.entity.Snowball fish = (org.bukkit.entity.Snowball) proj;
org.bukkit.entity.Entity shooter = fish.getShooter();
if (shooter instanceof org.bukkit.entity.Player) {
org.bukkit.entity.Player p = (org.bukkit.entity.Player) shooter;
Location loc = p.getLocation();
Material mat = p.getItemInHand().getType();
if (mat == Material.FISHING_ROD) {
p.setFallDistance(0);
p.playSound(loc, org.bukkit.Sound.ARROW_HIT, 1, 1);
int hitx = hit.getBlockX();
int hity = hit.getBlockY();
int hitz = hit.getBlockZ();
int locx = loc.getBlockX();
int locy = loc.getBlockY();
int locz = loc.getBlockZ();
double co[] = new double[3];
if (hitx > locx) co[0] = 1.2;
else if (hitx < locx) co[0] = -1.2;
else if (hitx == locx) co[0] = 0;
if (hity > locy) co[1] = 1.4;
else if (hity < locy) co[1] = -0.8;
else if (hity == locy) co[1] = 0;
if (hitz > locz) co[2] = 1.2;
else if (hitz < locz) co[2] = -1.2;
else if (hitz == locz) co[2] = 0;
p.setVelocity(new org.bukkit.util.Vector(co[0], co[1], co[2]));
}
}
}
}
Gun
The (in?)famous gun found on Wartown.
@EventHandler
public void gun(PlayerInteractEvent event) {
if (!event.getPlayer().getWorld().getName().equals(name)) return;
Player player = event.getPlayer();
Location loc = player.getLocation();
Action action = event.getAction();
ItemStack i = player.getItemInHand();
Inventory inv = player.getInventory();
Material tool = i.getType();
final World world = loc.getWorld();
if (tool.equals(Material.BLAZE_ROD)) {
if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
if (inv.contains(Material.FLINT)) {
player.launchProjectile(Arrow.class);
world.playSound(loc, Sound.COW_WALK, 10, 10);
ItemStack AMMO = new ItemStack(Material.FLINT, 1);
inv.removeItem(AMMO);
ItemMeta ammo = AMMO.getItemMeta();
ammo.setDisplayName(ChatColor.BLUE + "Ammunition");
AMMO.setItemMeta(ammo);
inv.removeItem(AMMO);
// Make it remove normal flints, too.
player.updateInventory();
} else {
world.playSound(loc, Sound.CLICK, 10, 10);
}
}
}
}
Enderpearl bow
The enderbow used on Xenon. This can be used to shoot any projectile too!
@EventHandler
public void onFireBow(org.bukkit.event.entity.EntityShootBowEvent event) {
if (getArena().equals(name)) {
if (event.getEntityType() == org.bukkit.entity.EntityType.PLAYER) {
org.bukkit.entity.Player player = (org.bukkit.entity.Player) event.getEntity();
if (player.getInventory().contains(Material.ARROW)) {
event.setCancelled(true);
player.getInventory().removeItem(new ItemStack(Material.ARROW, 1));
player.launchProjectile(org.bukkit.entity.EnderPearl.class).setVelocity(event.getProjectile().getVelocity());
} else {
event.setCancelled(true);
}
}
}
}
Ice Hook
The Ice Hook found on Arctic
@EventHandler
public void icePick(org.bukkit.event.player.PlayerInteractEvent event) {
org.bukkit.entity.Player p = event.getPlayer();
ItemStack i = p.getItemInHand();
Material mat = i.getType();
org.bukkit.event.block.Action a = event.getAction();
Location loc = p.getLocation();
if (loc.getWorld().getName().equals(name) && mat == Material.STONE_HOE &&
a == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK) {
org.bukkit.block.BlockFace f = event.getBlockFace();
org.bukkit.block.Block b = event.getClickedBlock();
Material Bmat = b.getType();
if (Bmat == Material.STONE || Bmat == Material.ICE && f != org.bukkit.block.BlockFace.UP
&& f != org.bukkit.block.BlockFace.DOWN) {
p.setVelocity(new org.bukkit.util.Vector(0, 1, 0));
p.setFallDistance(0);
w.playEffect(b.getLocation(), org.bukkit.Effect.STEP_SOUND, 79);
}
}
}
Nuke
The Nuke (Egg) found in Spire.
@EventHandler
public void superEgg(org.bukkit.event.player.PlayerEggThrowEvent event) {
org.bukkit.entity.Egg egg = event.getEgg();
World w = egg.getWorld();
Location location = egg.getLocation();
if (location.getWorld().getName().equals(name)) {
event.setHatching(true);
w.createExplosion(location, 25);
int strikes = 0;
while (strikes < 20) {
strikes++;
w.strikeLightning(location);
}
}
}
Turrets
The Turrets found in Spire. (Stand on top of them, your arrows become explosive)
@EventHandler
public void explodingArrow(org.bukkit.event.entity.ProjectileHitEvent event) {
org.bukkit.entity.Entity projectile = event.getEntity();
World w = projectile.getWorld();
Location hit = projectile.getLocation();
if (hit.getWorld().getName().equals(name)) {
if (projectile instanceof org.bukkit.entity.Arrow) {
org.bukkit.entity.Arrow arrow = (org.bukkit.entity.Arrow) projectile;
org.bukkit.entity.Entity shooter = arrow.getShooter();
Location l = shooter.getLocation();
org.bukkit.block.Block bl = l.getBlock();
org.bukkit.block.Block b = bl.getRelative(org.bukkit.block.BlockFace.DOWN, 2);
Material mat = b.getType();
if (shooter instanceof org.bukkit.entity.Player) {
org.bukkit.entity.Player p = (org.bukkit.entity.Player) shooter;
ItemStack is = p.getItemInHand();
Material i = is.getType();
if (i == Material.BOW && mat == Material.SPONGE) {
w.createExplosion(hit, 2);
Bukkit.getWorld(name).playEffect(arrow.getLocation(), org.bukkit.Effect.STEP_SOUND, 10);
}
}
}
}
}