Search in sources :

Example 1 with GameEvent

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);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 2 with GameEvent

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());
}
Also used : DuelFeature(com.voxelgameslib.voxelgameslib.api.feature.features.DuelFeature) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 3 with GameEvent

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");
    }
}
Also used : Location(org.bukkit.Location) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 4 with GameEvent

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);
    }
}
Also used : Player(org.bukkit.entity.Player) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 5 with GameEvent

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());
}
Also used : AbstractScoreboard(com.voxelgameslib.voxelgameslib.components.scoreboard.AbstractScoreboard) Scoreboard(com.voxelgameslib.voxelgameslib.components.scoreboard.Scoreboard) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Aggregations

GameEvent (com.voxelgameslib.voxelgameslib.api.event.GameEvent)8 AbstractScoreboard (com.voxelgameslib.voxelgameslib.components.scoreboard.AbstractScoreboard)2 Scoreboard (com.voxelgameslib.voxelgameslib.components.scoreboard.Scoreboard)2 Player (org.bukkit.entity.Player)2 DuelFeature (com.voxelgameslib.voxelgameslib.api.feature.features.DuelFeature)1 MapInfo (com.voxelgameslib.voxelgameslib.components.map.MapInfo)1 ItemBuilder (com.voxelgameslib.voxelgameslib.util.utils.ItemBuilder)1 Location (org.bukkit.Location)1 Sign (org.bukkit.block.Sign)1 ItemStack (org.bukkit.inventory.ItemStack)1 Vector (org.bukkit.util.Vector)1 InventoryMenuBuilder (org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder)1