Search in sources :

Example 6 with GameEvent

use of com.voxelgameslib.voxelgameslib.api.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.api.event.GameEvent)

Example 7 with GameEvent

use of com.voxelgameslib.voxelgameslib.api.event.GameEvent in project VoxelGamesLibv2 by VoxelGamesLib.

the class VoteFeature method openVoteMenu.

@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event, User user) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
        InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle("Vote for a map");
        for (int id : availableMaps.keySet()) {
            MapInfo info = availableMaps.get(id);
            ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getDisplayName()).lore(info.getAuthor()).build();
            builder.withItem(id - 1, item, (player, clickType, itemStack) -> confirmVote(user, id), ClickType.LEFT);
        }
        builder.show(user.getPlayer());
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.util.utils.ItemBuilder) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) MapInfo(com.voxelgameslib.voxelgameslib.components.map.MapInfo) ItemStack(org.bukkit.inventory.ItemStack) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 8 with GameEvent

use of com.voxelgameslib.voxelgameslib.api.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 (!Tag.WOODEN_PRESSURE_PLATES.isTagged(event.getClickedBlock().getType()) && event.getClickedBlock().getType() != Material.STONE_PRESSURE_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_ENDER_DRAGON_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.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