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);
}
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());
}
}
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);
}
}
Aggregations