use of com.voxelgameslib.voxelgameslib.api.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_ENDER_DRAGON_FLAP, 4, 1);
}
}
}
use of com.voxelgameslib.voxelgameslib.api.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class DuelVictoryCondition method onDeath.
@GameEvent
public void onDeath(@Nonnull PlayerDeathEvent e) {
if (completed())
return;
DuelFeature duelFeature = getPhase().getFeature(DuelFeature.class);
winner = duelFeature.getOther(e.getEntity().getUniqueId());
}
use of com.voxelgameslib.voxelgameslib.api.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class SpectatorFeature method onJoin.
@GameEvent(filterPlayers = false, filterSpectators = true)
public void onJoin(GameJoinEvent event) {
event.getUser().getPlayer().setGameMode(GameMode.SPECTATOR);
// spawn
Optional<SpawnFeature> spawnFeature = getPhase().getOptionalFeature(SpawnFeature.class);
if (spawns.size() > 0) {
Location location = spawns.get(ThreadLocalRandom.current().nextInt(spawns.size())).toLocation(map.getLoadedName(getPhase().getGame().getUuid())).add(0.5, 0, 0.5);
event.getUser().getPlayer().teleportAsync(location);
} else if (spawnFeature.isPresent()) {
event.getUser().getPlayer().teleportAsync(spawnFeature.get().getSpawn(event.getUser().getUuid()));
} else if (event.getGame().getPlayers().size() > 0) {
event.getUser().getPlayer().teleportAsync(event.getGame().getPlayers().get(0).getPlayer().getLocation());
} else {
log.warning("Could not figure out a spectator spawn point");
}
}
use of com.voxelgameslib.voxelgameslib.api.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.teleportAsync(getPhase().getFeature(SpawnFeature.class).getSpawn(player.getUniqueId()));
event.setCancelled(true);
}
}
use of com.voxelgameslib.voxelgameslib.api.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class PersonalScoreboardFeature method onQuit.
@GameEvent
public void onQuit(@Nonnull GamePreLeaveEvent event) {
Scoreboard scoreboard = scoreboards.get(event.getUser());
scoreboard.removeAllLines();
scoreboard.removeAllUsers();
scoreboards.remove(event.getUser());
}
Aggregations