use of com.voxelgameslib.voxelgameslib.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class VoidTeleportFeature method onVoidDamage.
@GameEvent
public void onVoidDamage(@Nonnull EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER)
return;
if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID)) {
Player player = (Player) event.getEntity();
player.teleport(getPhase().getFeature(SpawnFeature.class).getSpawn(player.getUniqueId()));
event.setCancelled(true);
}
}
use of com.voxelgameslib.voxelgameslib.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class JumpPadFeature method onStep.
@GameEvent
public void onStep(@Nonnull PlayerInteractEvent event) {
if (event.getAction() == Action.PHYSICAL) {
if (event.getClickedBlock().getType() != Material.WOOD_PLATE && event.getClickedBlock().getType() != Material.STONE_PLATE) {
return;
}
if (event.isCancelled()) {
return;
}
double strength = 1.5;
double up = 1;
if (event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState() instanceof Sign) {
Sign sign = (Sign) event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState();
if (sign.getLine(0).contains("[Boom]")) {
try {
strength = Double.parseDouble(sign.getLine(1));
up = Double.parseDouble(sign.getLine(2));
} catch (final Exception ex) {
log.warning("Invalid boom sign at " + sign.getLocation());
}
}
}
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 10.0F, 1.0F);
event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.SMOKE, 10);
Vector v = event.getPlayer().getLocation().getDirection().multiply(strength / 2).setY(up / 2);
event.getPlayer().setVelocity(v);
event.setCancelled(true);
}
}
use of com.voxelgameslib.voxelgameslib.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class PersonalScoreboardFeature method onQuit.
@GameEvent
public void onQuit(@Nonnull GameLeaveEvent event) {
Scoreboard scoreboard = scoreboards.get(event.getUser());
scoreboard.removeAllLines();
scoreboard.removeAllUsers();
scoreboards.remove(event.getUser());
}
use of com.voxelgameslib.voxelgameslib.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class DoubleJumpFeature method e.
@GameEvent
public void e(@Nonnull PlayerToggleFlightEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE) {
if (!disabled.contains(player.getUniqueId())) {
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(player.getLocation().getDirection().multiply(1.6).setY(1));
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 4, 1);
}
}
}
use of com.voxelgameslib.voxelgameslib.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class PersonalScoreboardFeature method onJoin.
@GameEvent
public void onJoin(@Nonnull GameJoinEvent event) {
Scoreboard scoreboard = scoreboardHandler.createScoreboard(getPhase().getGame().getGameMode().getName());
scoreboard.addUser(event.getUser());
scoreboards.put(event.getUser(), scoreboard);
}
Aggregations