org.bukkit.event.player.PlayerInteractEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerInteractEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Power.java From MineTinker with GNU General Public License v3.0 | 6 votes |
private void powerCreateFarmland(Player player, ItemStack tool, Block block) { if (block.getType().equals(Material.GRASS_BLOCK) || block.getType().equals(Material.DIRT)) { if (block.getWorld().getBlockAt(block.getLocation().add(0, 1, 0)).getType().equals(Material.AIR)) { if (tool.getItemMeta() instanceof Damageable) { Damageable damageable = (Damageable) tool.getItemMeta(); damageable.setDamage(damageable.getDamage() + 1); tool.setItemMeta((ItemMeta) damageable); } PlayerInteractEvent event = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, tool, block, BlockFace.UP); Bukkit.getPluginManager().callEvent(event); block.setType(Material.FARMLAND); // Event only does Plugin event (no vanilla conversion to Farmland and // Tool-Damage) } } }
Example #2
Source File: GunGizmo.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler public void playerInteract(final PlayerInteractEvent event) { if(event.getAction() == Action.PHYSICAL || !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo) || event.getItem() == null || event.getItem().getType() != this.getIcon()) return; final Player player = event.getPlayer(); RaindropUtil.giveRaindrops(Users.playerId(player), -1, new RaindropResult() { @Override public void run() { if(success) { Vector velocity = player.getLocation().getDirection().multiply(1.75D); Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(), new ItemStack(Material.GHAST_TEAR)); item.setVelocity(velocity); item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds items.put(item, player.getUniqueId()); } else { player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty", player)); player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1f, 1f); } } }, null, false, true, false); }
Example #3
Source File: LauncherGizmo.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (!(Gizmos.gizmoMap.get(player) instanceof LauncherGizmo)) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return; if (player.getItemInHand().getType() != this.getIcon()) return; Firework oldFirework = this.launchedPlayers.get(player); if (oldFirework == null || oldFirework.isDead()) { Firework firework = this.buildFirework(player.getLocation()); firework.setPassenger(player); this.launchedPlayers.put(player, firework); } }
Example #4
Source File: ButtonManager.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW) public void onInteract(PlayerInteractEvent event) { if(!event.hasItem()) return; final ClickType click; switch(event.getAction()) { case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: click = ClickType.LEFT; break; case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: click = ClickType.RIGHT; break; default: return; } if(onButtonClick(event.getItem(), event.getActor(), click, event)) { event.setUseItemInHand(Event.Result.DENY); event.setUseInteractedBlock(Event.Result.DENY); } }
Example #5
Source File: AntiGriefListener.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void cloneCraftingWindow(final PlayerInteractEvent event) { if (!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getOpenInventory().getType() == InventoryType.CRAFTING /* nothing open */) { Block block = event.getClickedBlock(); if (block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) { // create the window ourself event.setCancelled(true); event.getPlayer().openWorkbench(null, true); // doesn't check reachable } } }
Example #6
Source File: AntiGriefListener.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void checkDefuse(final PlayerInteractEvent event) { ItemStack hand = event.getPlayer().getItemInHand(); if (hand == null || hand.getType() != DEFUSE_ITEM) return; MatchPlayer clicker = this.mm.getPlayer(event.getPlayer()); if (clicker != null && clicker.isObserving() && clicker.getBukkit().hasPermission(Permissions.DEFUSE)) { if (event.getAction() == Action.RIGHT_CLICK_AIR) { this.obsTntDefuse(clicker, event.getPlayer().getLocation()); } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { this.obsTntDefuse(clicker, event.getClickedBlock().getLocation()); } } }
Example #7
Source File: Tutorial.java From CardinalPGM with MIT License | 6 votes |
@EventHandler public void onPlayerRightClick(PlayerInteractEvent event) { boolean condition = Teams.getTeamByPlayer(event.getPlayer()).isPresent() && Teams.getTeamByPlayer(event.getPlayer()).get().isObserver() && event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType().equals(Material.EMERALD); if (!this.displayHandlerMap.containsKey(event.getPlayer())) { this.displayHandlerMap.put(event.getPlayer(), new DisplayHandler(event.getPlayer(), this)); } if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && condition) { this.displayHandlerMap.get(event.getPlayer()).displayNext(); } if ((event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) && condition) { this.displayHandlerMap.get(event.getPlayer()).displayPrev(); } }
Example #8
Source File: TeleporterListener.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPressurePlateEnter(PlayerInteractEvent e) { if (e.getAction() != Action.PHYSICAL || e.getClickedBlock() == null) { return; } String id = BlockStorage.checkID(e.getClickedBlock()); if (id == null) { return; } if (isTeleporterPad(id, e.getClickedBlock(), e.getPlayer().getUniqueId())) { SlimefunItem teleporter = BlockStorage.check(e.getClickedBlock().getRelative(BlockFace.DOWN)); if (teleporter instanceof Teleporter && checkForPylons(e.getClickedBlock().getRelative(BlockFace.DOWN))) { Block block = e.getClickedBlock().getRelative(BlockFace.DOWN); UUID owner = UUID.fromString(BlockStorage.getLocationInfo(block.getLocation(), "owner")); SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(e.getPlayer(), owner, block, SlimefunPlugin.getGPSNetwork().getNetworkComplexity(owner)); } } else if (id.equals(SlimefunItems.ELEVATOR_PLATE.getItemId())) { ((ElevatorPlate) SlimefunItems.ELEVATOR_PLATE.getItem()).open(e.getPlayer(), e.getClickedBlock()); } }
Example #9
Source File: RegionMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
private void handleUse(Event event, BlockState blockState, MatchPlayer player) { if (!player.canInteract()) return; PlayerBlockQuery query = new PlayerBlockQuery(event, player, blockState); for (RegionFilterApplication rfa : this.rfaContext.get(RFAScope.USE)) { if (rfa.region.contains(blockState)) { if (processQuery(rfa, query)) { if (query.getEvent() instanceof PlayerInteractEvent && ((PlayerInteractEvent) query.getEvent()).isCancelled()) { PlayerInteractEvent pie = (PlayerInteractEvent) query.getEvent(); pie.setCancelled(false); pie.setUseItemInHand(Event.Result.ALLOW); pie.setUseInteractedBlock(Event.Result.DENY); if (rfa.message != null) { player.sendWarning(rfa.message); } } if (this.useRegionPriority || rfa.useRegionPriority) { break; } } } } }
Example #10
Source File: SpawnEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onSpawnEggEvent(PlayerInteractEvent event) { Player player = event != null ? event.getPlayer() : null; if (player == null || event.isCancelled() || !plugin.getWorldManager().isSkyWorld(player.getWorld())) { return; // Bail out, we don't care } if (player.hasPermission("usb.mod.bypassprotection") || player.isOp()) { return; } ItemStack item = event.getItem(); if (RIGHT_CLICKS.contains(event.getAction()) && item != null && isSpawnEgg(item)) { if (!plugin.playerIsOnIsland(player)) { event.setCancelled(true); plugin.notifyPlayer(player, tr("\u00a7eYou can only use spawn-eggs on your own island.")); return; } SpawnEgg spawnEgg = (SpawnEgg) item.getData(); checkLimits(event, spawnEgg.getSpawnedType(), player.getLocation()); if (event.isCancelled()) { plugin.notifyPlayer(player, tr("\u00a7cYou have reached your spawn-limit for your island.")); event.setUseItemInHand(Event.Result.DENY); event.setUseInteractedBlock(Event.Result.DENY); } } }
Example #11
Source File: FlagQueueLobby.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { SpleefPlayer player = getHeavySpleef().getSpleefPlayer(event.getPlayer()); if (!game.isQueued(player)) { return; } MetadatableItemStack inHand = new MetadatableItemStack(player.getBukkitPlayer().getItemInHand()); if (!inHand.hasItemMeta() || !inHand.getItemMeta().hasLore() || !inHand.hasMetadata(LEAVE_ITEM_KEY)) { return; } //Leave the queue mode game.unqueue(player); player.sendMessage(getI18N().getVarString(Messages.Command.REMOVED_FROM_QUEUE) .setVariable("game", game.getName()) .toString()); }
Example #12
Source File: SkullPlaceHolders.java From VoxelGamesLibv2 with MIT License | 6 votes |
@EventHandler public void handleInteract(@Nonnull PlayerInteractEvent event) { if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) { if (event.getClickedBlock().getState() instanceof Skull) { Skull skull = (Skull) event.getClickedBlock().getState(); if (skull.hasMetadata("UpdateCooldown")) { long cooldown = skull.getMetadata("UpdateCooldown").get(0).asLong(); if (cooldown > System.currentTimeMillis() - 1 * 1000) { return; } } skull.update(); skull.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis())); } } }
Example #13
Source File: LecternInteractListener.java From ViaBackwards with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onLecternInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (!isOnPipe(player)) return; Block block = event.getClickedBlock(); if (block == null || block.getType() != Material.LECTERN) return; Lectern lectern = (Lectern) block.getState(); ItemStack book = lectern.getInventory().getItem(0); if (book == null) return; BookMeta meta = (BookMeta) book.getItemMeta(); // Open a book with the text of the lectern's writable book ItemStack newBook = new ItemStack(Material.WRITTEN_BOOK); BookMeta newBookMeta = (BookMeta) newBook.getItemMeta(); newBookMeta.setPages(meta.getPages()); newBookMeta.setAuthor("an upsidedown person"); newBookMeta.setTitle("buk"); newBook.setItemMeta(newBookMeta); player.openBook(newBook); event.setCancelled(true); }
Example #14
Source File: EntityRemoverTool.java From NBTEditor with GNU General Public License v3.0 | 6 votes |
@Override public void onRightClick(PlayerInteractEvent event, PlayerDetails details) { Player player = event.getPlayer(); if (player.isSneaking()) { Location location = event.getPlayer().getLocation(); int i = 0; for (Entity entity : location.getWorld().getNearbyEntities(location, _radius, _radius, _radius)) { if (entity.getType() != EntityType.PLAYER) { entity.remove(); i++; } } if (i == 1) { player.sendMessage(ChatColor.GREEN + "Removed " + i + " entity."); } else if (i != 0) { player.sendMessage(ChatColor.GREEN + "Removed " + i + " entities."); } else { player.sendMessage(ChatColor.YELLOW + "No entities on a " + _radius + " block radius."); } } }
Example #15
Source File: SignEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onPlayerHitSign(PlayerInteractEvent e) { if (e.isCancelled() || e.getPlayer() == null || (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.LEFT_CLICK_BLOCK) || e.getClickedBlock() == null || e.getClickedBlock().getType() != SkyBlockMenu.WALL_SIGN_MATERIAL || !(e.getClickedBlock().getState() instanceof Sign) || !e.getPlayer().hasPermission("usb.island.signs.use") || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getWorld()) || !(plugin.playerIsOnOwnIsland(e.getPlayer())) ) { return; } if (e.getAction() == Action.LEFT_CLICK_BLOCK) { logic.updateSign(e.getClickedBlock().getLocation()); } else { logic.signClicked(e.getPlayer(), e.getClickedBlock().getLocation()); } }
Example #16
Source File: RescuePlatformListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onInteract(PlayerInteractEvent ev) { if (ev.getAction().equals(Action.LEFT_CLICK_AIR) || ev.getAction().equals(Action.LEFT_CLICK_BLOCK)) { return; } Player player = ev.getPlayer(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.RUNNING) { return; } RescuePlatform platform = new RescuePlatform(); if (!ev.getMaterial().equals(platform.getItemMaterial())) { return; } platform.create(player, game); }
Example #17
Source File: SlimefunItemListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onRightClick(PlayerInteractEvent e) { if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { if (SlimefunUtils.isItemSimilar(e.getItem(), SlimefunItems.DEBUG_FISH, true)) { return; } PlayerRightClickEvent event = new PlayerRightClickEvent(e); Bukkit.getPluginManager().callEvent(event); boolean itemUsed = e.getHand() == EquipmentSlot.OFF_HAND; if (event.useItem() != Result.DENY) { rightClickItem(e, event, itemUsed); } if (!itemUsed && event.useBlock() != Result.DENY && !rightClickBlock(e, event)) { return; } if (e.useInteractedBlock() != Result.DENY) { e.setUseInteractedBlock(event.useBlock()); } if (e.useItemInHand() != Result.DENY) { e.setUseItemInHand(event.useItem()); } } }
Example #18
Source File: MainListener.java From ArmorStandTools with MIT License | 5 votes |
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { final Player p = event.getPlayer(); if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) { plugin.carryingArmorStand.remove(p.getUniqueId()); Utils.actionBarMsg(p, Config.asDropped); p.setMetadata("lastDrop", new FixedMetadataValue(plugin, System.currentTimeMillis())); event.setCancelled(true); } else { p.sendMessage(ChatColor.RED + Config.wgNoPerm); } return; } ArmorStandTool tool = ArmorStandTool.get(event.getItem()); if(tool == null) return; event.setCancelled(true); Action action = event.getAction(); if(action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) { Utils.cycleInventory(p); } else if((action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) && tool == ArmorStandTool.SUMMON) { if (!plugin.playerHasPermission(p, event.getClickedBlock(), tool)) { p.sendMessage(ChatColor.RED + Config.generalNoPerm); return; } Location l = Utils.getLocationFacing(p.getLocation()); plugin.pickUpArmorStand(spawnArmorStand(l), p, true); Utils.actionBarMsg(p, Config.carrying); } new BukkitRunnable() { @Override public void run() { //noinspection deprecation p.updateInventory(); } }.runTaskLater(plugin, 1L); }
Example #19
Source File: JumpPadFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@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); } }
Example #20
Source File: Cannon.java From civcraft with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") public void processAngle(PlayerInteractEvent event) throws CivException { validateUse(event.getPlayer()); if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) { this.angle -= STEP; if (this.angle < minAngle) { this.angle = minAngle; } } else if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { this.angle += STEP; if (this.angle > maxAngle) { this.angle = maxAngle; } } double a = this.angle; if (this.angleFlip) { a *= -1; } if (signDirection == WALLSIGN_EAST || signDirection == WALLSIGN_WEST) { direction.setZ(a / 100); } else { // NORTH/SOUTH direction.setX(a / 100); } event.getPlayer().updateInventory(); updateAngleSign(this.angleSignLocation.getBlock()); }
Example #21
Source File: Compat19.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent event) { Player p = event.getPlayer(); Block b = event.getClickedBlock(); ItemStack itemInHand = event.getItem(); Location l; if (b != null) { l = b.getLocation(); RedProtect.get().logger.debug(LogLevel.DEFAULT, "PlayerListener - Is PlayerInteractEvent event. The block is " + b.getType().name()); } else { l = p.getLocation(); } if (RedProtect.get().tpWait.contains(p.getName())) { RedProtect.get().tpWait.remove(p.getName()); RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpcancelled"); } if (itemInHand != null && (event.getAction().name().equals("RIGHT_CLICK_BLOCK") || b == null)) { Material hand = itemInHand.getType(); Region r = RedProtect.get().rm.getTopRegion(l); // Deny chorus teleport if (r != null && hand.equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse"); event.setCancelled(true); event.setUseItemInHand(Event.Result.DENY); } // Deny glide boost if (r == null && p.isGliding() && itemInHand.getType().name().contains("FIREWORK") && !p.hasPermission("redprotect.bypass.glide") && !RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_boost) { event.setUseItemInHand(Event.Result.DENY); event.setCancelled(true); RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantboost"); } } }
Example #22
Source File: VoteFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@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()); } }
Example #23
Source File: GameMap.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void signClickCheck(PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK_BLOCK) { Block b = event.getClickedBlock(); if(b != null) { //Bukkit.getLogger().info("Error test 1"); if(b.getType() == Material.FURNACE || b.getType() == Material.BURNING_FURNACE) { //Bukkit.getLogger().info("Error test 1"); MapKey key = MapKey.getKey(b.getLocation()); if(this.enderFurnaces.containsKey(key)) { //Bukkit.getLogger().info("Error test 2"); event.setCancelled(true); AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId()); if(p != null) { // Bukkit.getLogger().info("Error test 3"); // if(p.getFurnace() != null) // { // Bukkit.getLogger().info("Error test 4"); p.openFurnace(); // } // else // Bukkit.getLogger().warning("[Annihilation] Someones enderfurnace was null!"); } } } } } }
Example #24
Source File: MapRatingsMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler public void onOpenButtonClick(PlayerInteractEvent event) { if(event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; MatchPlayer player = this.getMatch().getPlayer(event.getPlayer()); if(player == null) return; ItemStack stack = event.getPlayer().getItemInHand(); if(stack == null) return; if(stack.getType() != Material.HOPPER) return; String name = stack.getItemMeta().getDisplayName(); if(name == null || !name.startsWith(BUTTON_PREFIX)) return; this.showDialog(player); }
Example #25
Source File: RangedAttack.java From civcraft with GNU General Public License v2.0 | 5 votes |
@Override public void onInteract(PlayerInteractEvent event) { if (Unit.isWearingAnyMetal(event.getPlayer())) { event.setCancelled(true); CivMessage.sendError(event.getPlayer(), "Cannot use a bow while wearing metal armor."); return; } }
Example #26
Source File: MapBuilder.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority=EventPriority.HIGH) public void openMapBuilderCheck(PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { final Player player = event.getPlayer(); if(KitUtils.itemHasName(player.getItemInHand(), CustomItem.MAPBUILDER.getName())) { this.openMapBuilder(player); event.setCancelled(true); } } }
Example #27
Source File: EventRuleMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void checkUse(final PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK_BLOCK) { MatchPlayer player = this.match.getParticipant(event.getPlayer()); if(player == null) return; Block block = event.getClickedBlock(); if(block == null) return; this.handleUse(event, block.getState(), player); } }
Example #28
Source File: LWCEntityListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent e) { ItemStack inHand = e.getItem(); if (inHand != null) { placedArmorStandPlayer = e.getPlayer().getUniqueId(); } }
Example #29
Source File: EvtPressurePlate.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean check(final Event e) { final Block b = ((PlayerInteractEvent) e).getClickedBlock(); final Material type = b == null ? null : b.getType(); return type != null && ((PlayerInteractEvent) e).getAction() == Action.PHYSICAL && (tripwire ? (type == Material.TRIPWIRE || type == Material.TRIPWIRE_HOOK) : plate.isOfType(type)); }
Example #30
Source File: Player116ListenerUtils.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static boolean anchorCharge(PlayerInteractEvent event, Game game, ItemStack stack) { boolean anchorFilled = false; RespawnAnchor anchor = (RespawnAnchor) event.getClickedBlock().getBlockData(); int charges = anchor.getCharges(); charges++; if (charges <= anchor.getMaximumCharges()) { anchorFilled = true; anchor.setCharges(charges); event.getClickedBlock().setBlockData(anchor); stack.setAmount(stack.getAmount() - 1); Sounds.playSound(event.getClickedBlock().getLocation(), Main.getConfigurator().config.getString("target-block.respawn-anchor.sound.charge"), Sounds.BLOCK_RESPAWN_ANCHOR_CHARGE, 1, 1); game.updateScoreboard(); } return anchorFilled; }