166 lines
5.5 KiB
Java
166 lines
5.5 KiB
Java
package eu.univento.lobby.listeners;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Effect;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
import org.bukkit.util.Vector;
|
|
|
|
import eu.univento.core.api.Config;
|
|
import eu.univento.core.api.CustomPlayer;
|
|
import eu.univento.core.api.Messages;
|
|
import eu.univento.core.api.Perms.Ranks;
|
|
import eu.univento.lobby.Lobby;
|
|
|
|
/**
|
|
* fun for player
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Jumppads implements Listener{
|
|
|
|
/**
|
|
* contains players flying from premium lobby
|
|
*/
|
|
private ArrayList<CustomPlayer> fly = new ArrayList<CustomPlayer>();
|
|
|
|
/**
|
|
* lets players jump over pads
|
|
* @param e PlayerMoveEvent
|
|
* @throws InterruptedException thread closed
|
|
*/
|
|
@SuppressWarnings("deprecation")
|
|
@EventHandler
|
|
public void onMove(PlayerMoveEvent e) throws InterruptedException {
|
|
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
|
|
|
if(p.getLocation().getBlock().getType() == Material.STONE_PLATE) {
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.REDSTONE_BLOCK) {
|
|
Vector v = p.getLocation().getDirection().multiply(3D).setY(1D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.BEDROCK) {
|
|
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.IRON_BLOCK) {
|
|
Vector v = p.getLocation().getDirection().multiply(3D).setY(4D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.DIAMOND_BLOCK) {
|
|
if(p.isAllowed(Ranks.Premium)) {
|
|
Vector v = p.getLocation().getDirection().multiply(6D).setY(3D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
|
|
|
@Override
|
|
public void run() {
|
|
p.teleport(Config.readLocation("Lobby.Locs.PremiumHub"));
|
|
}
|
|
|
|
}, 60L);
|
|
}else {
|
|
p.sendMessage(Messages.readString("Messages.Commands.NoPerms"));
|
|
}
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.OBSIDIAN) {
|
|
Vector v = p.getLocation().getDirection().multiply(3D).setY(1D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.LAPIS_BLOCK) {
|
|
Vector v = p.getLocation().getDirection().multiply(6D).setY(1D);
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
|
}
|
|
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.EMERALD_BLOCK) {
|
|
if(!fly.contains(p)) {
|
|
Vector v = p.getLocation().getDirection().multiply(10.0D).setY(10.0D);
|
|
p.setVelocity(v);
|
|
fly.add(p);
|
|
p.setHealth(1.0);
|
|
p.setFoodLevel(20);
|
|
for(Player players : Bukkit.getOnlinePlayers()) {
|
|
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
|
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER) {
|
|
if(fly.contains(p)) {
|
|
fly.remove(p);
|
|
p.teleport(Bukkit.getWorld("world").getSpawnLocation());
|
|
p.playSound(p.getEyeLocation(), Sound.ENDERMAN_TELEPORT, 5.0F, 1.0F);
|
|
p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 20);
|
|
p.playEffect(p.getEyeLocation(), Effect.HEART, 20);
|
|
p.setHealth(10.0);
|
|
p.setFoodLevel(10);
|
|
}
|
|
}
|
|
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.SPONGE) {
|
|
Vector v = p.getLocation().getDirection().multiply(0.0D).setY(1.0D);
|
|
Block b = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
|
p.setVelocity(v);
|
|
p.playSound(p.getEyeLocation(), Sound.SPLASH, 5.0F, 1.0F);
|
|
p.playEffect(p.getEyeLocation(), Effect.SPLASH, 200);
|
|
Block block = p.getLocation().add(0.0D, 5.0D, 0.0D).getBlock();
|
|
block.setType(Material.WATER);
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
|
|
|
@Override
|
|
public void run() {
|
|
block.setType(Material.AIR);
|
|
|
|
}
|
|
|
|
}, 20L);
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
|
|
|
@Override
|
|
public void run() {
|
|
b.setType(Material.SPONGE);
|
|
for(Player players : Bukkit.getOnlinePlayers()) {
|
|
players.playSound(b.getLocation(), Sound.PISTON_EXTEND, 1.0F, 1.0F);
|
|
players.playEffect(b.getLocation(), Effect.LARGE_SMOKE, 10);
|
|
}
|
|
}
|
|
|
|
}, 60L);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* cancels fall damage
|
|
* @param e EntityDamageEvent
|
|
*/
|
|
@EventHandler
|
|
public void onDamage(EntityDamageEvent e) {
|
|
if(e.getEntity() instanceof Player) {
|
|
if(e.getCause() == DamageCause.FALL) {
|
|
e.setCancelled(true);
|
|
}
|
|
}
|
|
}
|
|
} |