Search in sources :

Example 1 with GameEvent

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

Example 2 with GameEvent

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);
    }
}
Also used : Sign(org.bukkit.block.Sign) Vector(org.bukkit.util.Vector) GameEvent(com.voxelgameslib.voxelgameslib.event.GameEvent)

Example 3 with GameEvent

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

Example 4 with GameEvent

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

Example 5 with GameEvent

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

Aggregations

GameEvent (com.voxelgameslib.voxelgameslib.event.GameEvent)7 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.feature.features.DuelFeature)1 MapInfo (com.voxelgameslib.voxelgameslib.map.MapInfo)1 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)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