@Override public void shoot(PlayerInteractEvent event) { if (event.getMaterial() == null) return; final List<String> itemLore = event.getItem().getItemMeta().getLore(); if (WeaponWatch.durability.get(itemLore) == null) WeaponWatch.durability.put(itemLore, 4); if (WeaponWatch.durability.get(itemLore) == 0) return; if (WeaponWatch.cooldown.contains(itemLore)) return; if (shotsLeft.get(itemLore) != null && shotsLeft.get(itemLore) == 0) { WeaponWatch.cooldown.add(itemLore); shotsLeft.remove(itemLore); new BukkitRunnable() { @Override public void run() { WeaponWatch.durability.put(itemLore, WeaponWatch.durability.get(itemLore) - 1); WeaponWatch.cooldown.remove(itemLore); } }.runTaskLater(DuckMain.getPlugin(), 80); } int shotsPerRound = 6; // @Balancing: Specify shots per round here if (shotsLeft.get(itemLore) == null) shotsLeft.put(itemLore, shotsPerRound); else shotsLeft.put(itemLore, shotsLeft.get(itemLore) - 1); DuckMain.getWorld().playSound(event.getPlayer().getLocation(), Sound.ENTITY_BLAZE_HURT, 10, 1); Arrow a = event .getPlayer() .launchProjectile(Arrow.class, event.getPlayer().getLocation().getDirection()); a.setShooter(event.getPlayer()); a.setVelocity(a.getVelocity().multiply(6)); a.setCustomName("MachineGun"); }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(final PlayerInteractEvent event) { final IUser user = userMap.getUser(event.getPlayer()); user.updateActivity(true); switch (event.getAction()) { case RIGHT_CLICK_BLOCK: if (event.isCancelled()) { return; } final ISettings settings = ess.getSettings(); if (settings.getData().getCommands().getHome().isUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK) { event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation()); } break; case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: if (user.getData().hasPowerTools() && user.getData().isPowerToolsEnabled()) { if (usePowertools(user)) { event.setCancelled(true); } } break; default: break; } }
@EventHandler public void onPlayerBlockInteract(PlayerInteractEvent event) { if (VAR.config.getBoolean("enableRules")) { if (!VAR.pLog .getString("players." + event.getPlayer().getName() + ".Has accepted rules") .equalsIgnoreCase("true")) { if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) return; String msg = VAR.config.getString("RulesNotAcceptedMsg"); msg = ip.replace(msg, event.getPlayer()); if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("chest")) { if (event.getClickedBlock().getTypeId() == 54) { event.getPlayer().sendMessage(msg); event.setCancelled(true); return; } } if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("redstone")) { int ID = event.getClickedBlock().getTypeId(); if (ID == 69 || ID == 70 || ID == 72 || ID == 77) { event.getPlayer().sendMessage(msg); event.setCancelled(true); return; } } } } }
// ================================================================================================ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (plugin.posIsWithinColdBiome( event.getPlayer().getTargetBlock(null, 5).getX(), event.getPlayer().getTargetBlock(null, 5).getZ())) { Block targetedBlock = event .getPlayer() .getTargetBlock( null, 5); // first arg is transparent block, second arg is maxDistance to scan. 5 is // default reach for players. if ((null != targetedBlock) && (targetedBlock.getType() == Material.FIRE)) { // check if player is about to extinguish a registered fire with his hands or a tool (and // not a Block) if (plugin.blockIsRegisteredFire( targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ())) { plugin.removeDiedFireFromFireList( targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ()); if (Arctica.debug) { event.getPlayer().sendMessage(ChatColor.AQUA + "Feuerstelle aus Liste geloescht!"); } } } } } }
@EventHandler public void onPlayerInteractEvent(PlayerInteractEvent event) { if (!isEnabled()) return; try { if (event.hasBlock() && event.getClickedBlock().getType() == Material.SIGN) return; if (event.hasItem() && event.useItemInHand() != Event.Result.DENY) { ForgePermittor.log( "ItemType: " + getValidator().CheckItem(event.getItem()).toString(), true); if (!getProtectionManager() .CanUseItem( event.getPlayer(), event.getPlayer().getLocation(), getValidator().CheckItem(event.getItem()))) { event.setUseItemInHand(Event.Result.DENY); event.setUseInteractedBlock(Event.Result.DENY); return; } } if (event.hasBlock() && event.useInteractedBlock() != Event.Result.DENY) { ForgePermittor.log( "BlockType: " + getValidator().CheckBlock(event.getClickedBlock()).toString(), true); if (!getProtectionManager() .CanUseBlock( event.getPlayer(), event.getClickedBlock(), getValidator().CheckBlock(event.getClickedBlock()))) { event.setUseInteractedBlock(Event.Result.DENY); } } } catch (Exception e) { e.printStackTrace(); } }
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { int BLWand = getConfig().getInt("blocklog.wand"); boolean WandEnabled = plugin.users.contains(event.getPlayer().getName()); if (!event.isCancelled()) { if (event.getPlayer().getItemInHand().getTypeId() == BLWand && WandEnabled) { if ((event.getAction() == Action.RIGHT_CLICK_BLOCK && (!event.getPlayer().getItemInHand().getType().isBlock()) || event.getAction() == Action.LEFT_CLICK_BLOCK)) { Material type = event.getClickedBlock().getType(); if (type == Material.WOODEN_DOOR || type == Material.TRAP_DOOR || type == Material.CHEST || type == Material.DISPENSER || type == Material.STONE_BUTTON || type == Material.LEVER) getBlockInteractions( event.getPlayer(), event.getClickedBlock(), Interaction.getByMaterial(type)); else getBlockEdits(event.getPlayer(), event.getClickedBlock()); event.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) return; if (event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK || event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) { PlayerEvent playerEvent; if (SignUtil.isSign(event.getClickedBlock())) { playerEvent = new PlayerEvent( SignUtil.getSign(event.getClickedBlock()), event.getAction() == Action.LEFT_CLICK_BLOCK ? PlayerEvent.Action.LEFT_CLICK : PlayerEvent.Action.RIGHT_CLICK, event.getPlayer(), event); } else { playerEvent = new PlayerEvent( event.getClickedBlock(), event.getAction() == Action.LEFT_CLICK_BLOCK ? PlayerEvent.Action.LEFT_CLICK : PlayerEvent.Action.RIGHT_CLICK, event.getPlayer(), event); } mechanicsHandler.callPlayerEvent(playerEvent); } }
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerInteract(PlayerInteractEvent e) { ItemStack stack = e.getItem(); if (e.getPlayer().isOp()) { if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && stack != null && stack.getType().equals(wand)) { if (a.get(e.getPlayer().getName()) == null || (b.get(e.getPlayer().getName()) != null && a.get(e.getPlayer().getName()) != null)) { a.put(e.getPlayer().getName(), e.getClickedBlock().getLocation()); b.remove(e.getPlayer().getName()); e.getPlayer() .sendMessage( ChatColor.AQUA + "Selected block A: " + e.getClickedBlock().getLocation().toVector().toString()); } else if (b.get(e.getPlayer().getName()) == null) { b.put(e.getPlayer().getName(), e.getClickedBlock().getLocation()); e.getPlayer() .sendMessage( ChatColor.AQUA + "Selected block B: " + e.getClickedBlock().getLocation().toVector().toString()); } } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteract(PlayerInteractEvent e) { if (e.getItem() != null && e.getItem().getType() == selectionTools && e.getClickedBlock() != null && e.getPlayer().isOp()) { Region v = this.selections.get(e.getPlayer().getName()); if (v == null) { v = new Region(null, null); this.selections.put(e.getPlayer().getName(), v); } Location l = e.getClickedBlock().getLocation(); if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { v.setEnd(l); if (plugin.portalRegionSelectionMessage) e.getPlayer().sendMessage("[BungeeSuiteBukkit] Second point set"); } else if (e.getAction() == Action.LEFT_CLICK_BLOCK) { v.setFirst(l); if (plugin.portalRegionSelectionMessage) e.getPlayer().sendMessage("[BungeeSuiteBukkit] First point set"); } } }
@EventHandler public void onPlayerClickTool(PlayerInteractEvent event) { Location location = null; try { Block clicked = event.getClickedBlock(); if ((clicked != null) && (event.getAction() == Action.RIGHT_CLICK_BLOCK)) { Block relative = clicked.getRelative(event.getBlockFace()); location = relative.getLocation(); } else { BlockIterator iterator = new BlockIterator(event.getPlayer(), 16); Block target = null; while (iterator.hasNext()) { Block block = iterator.next(); if (block.getType() != Material.AIR) { target = iterator.next(); break; } } if (target != null) location = target.getLocation(); } } catch (Exception e) { } if (setBlock(event.getPlayer(), event.getPlayer().getItemInHand(), location)) { event.setCancelled(true); } }
/** * Called when a player clicks on anything. * * @param event The Interact event. */ @EventHandler public void playerInteract(PlayerInteractEvent event) { if (event.isCancelled()) { return; } if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getClickedBlock().getState() instanceof Sign) { this.plugin.log(Level.FINER, "Found a Sign!"); Sign s = (Sign) event.getClickedBlock().getState(); SignStatus status = this.pd.getSignStatus(s); if (status == SignStatus.SignPortal) { String destString = this.pd.processSign(s); this.takePlayerToDestination(event.getPlayer(), destString); event.setCancelled(true); } else if (status == SignStatus.Disabled) { this.pd.activateSignPortal(event.getPlayer(), ChatColor.RED + "Disabled", s); event.setCancelled(true); } else if (status == SignStatus.Legacy) { this.pd.activateSignPortal(event.getPlayer(), ChatColor.AQUA + "Legacy", s); event.setCancelled(true); } else if (status == SignStatus.NetherPortalSign) { event.setCancelled(true); } } } }
@Override public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) if (event.getPlayer().getItemInHand().getType() == Material.SULPHUR) if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.LAPIS_BLOCK) Cannon.fire(event.getPlayer()); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent event) { if (event == null) return; if (event.getPlayer() == null) event.setCancelled(true); if (validateAuthorizer(event.getPlayer())) event.setCancelled(true); else if (validateClickAuth(event.getPlayer(), event.getAction())) event.setCancelled(true); }
@Override public boolean onInteract(PlayerInteractEvent e, int level) { for (int i = 0; i < level; i++) { e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.OCELOT); } return true; }
@EventHandler public void throwSnowball(PlayerInteractEvent e) { final Player p = e.getPlayer(); if (UtilBlock.usable(e.getClickedBlock())) { return; } if (e.getPlayer().getItemInHand() == null) { return; } if (e.getPlayer().getItemInHand().getType() != Material.FIREWORK_CHARGE) { return; } if (_coolDown.contains(p.getUniqueId())) { return; } if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (disName(p.getItemInHand()) != null) && (disName(p.getItemInHand()) .equalsIgnoreCase( ChatColor.DARK_AQUA + "EnderDoge " + ChatColor.DARK_RED + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)))) { Player player = e.getPlayer(); e.setCancelled(true); _coolDown.add(p.getUniqueId()); Bukkit.getScheduler() .runTaskLater( Main.getInstance(), new Runnable() { public void run() { _coolDown.remove(p.getUniqueId()); } }, 5L); Projectile proj = player.launchProjectile(Snowball.class); proj.setVelocity(proj.getVelocity().multiply(2)); _balls.add(proj); player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5F, 1.5F); EnderDogeAmmoManager.takeEnderDogeAmmo(p, 1); if (EnderDogeAmmoManager.balaceEnderDogeAmmo(p) < 1) { player.getInventory().setItemInHand(null); player.sendMessage( StringManager.getPrefix(MessageType.ERROR) + ChatColor.AQUA + "You ran out of ammo!"); return; } ItemStack snow = new ItemStack(Material.FIREWORK_CHARGE, 1); ItemMeta sno = snow.getItemMeta(); sno.setDisplayName( ChatColor.DARK_AQUA + "EnderDoge " + ChatColor.DARK_RED + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)); snow.setItemMeta(sno); player.getInventory().setItemInHand(snow); } }
@Override public boolean onInteract(PlayerInteractEvent e, int level) { e.getPlayer() .addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 20 * level)); e.getPlayer().sendMessage("Upped your fire resistance!"); return true; }
public void onPlayerInteract(PlayerInteractEvent event) { String eventplayer = event.getPlayer().getName(); if (admin.freeze.contains(eventplayer)) { // cancel here event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "Can't do that while frozen!"); } }
@Override public void onRightClick(PlayerInteractEvent event) { if (!plugin.getLocalConfiguration().cauldronSettings.enable) return; if (!BukkitUtil.toWorldVector(event.getClickedBlock()).equals(pt)) return; // wth? our manager is insane if (event.getPlayer().getItemInHand().getTypeId() >= 255 || event.getPlayer().getItemInHand().getType() == Material.AIR) preCauldron(event.getPlayer(), event.getPlayer().getWorld(), pt); }
@EventHandler public void onTurretFire(PlayerInteractEvent e) { if (isInTurret(e.getPlayer())) { Player shooter = e.getPlayer(); Turret t = getTurret(shooter); t.shoot(); } }
@EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR) { return; } if (!event.getPlayer().hasPermission("permissions.build")) { bother(event.getPlayer()); event.setCancelled(true); } }
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { return; } if (event.getClickedBlock() == null || event.getClickedBlock().getType() == Material.AIR) { return; } if (!context.isValidWorld(event.getPlayer().getWorld().getName())) return; SafeCityPlayer scPlayer = context.getPlayer(event.getPlayer()); if (scPlayer.getCoolDownState()) { return; } if (scPlayer.getZoneManager().isResizing()) { return; } boolean hasTool = false; if (scPlayer.getBukkitPlayer().getItemInHand().getType() == SafeCityTool.ZoneTool.material()) { hasTool = true; } if (scPlayer.getBukkitPlayer().getItemInHand().getType() == SafeCityTool.ZoneTool3d.material()) { hasTool = true; } if (!hasTool) { return; } World blockWorld = event.getClickedBlock().getWorld(); Location blockLocation = event.getClickedBlock().getLocation(); ThinLocation blockThinLocation = context.toThinLocation(blockLocation); // does a zone already exist here? SafeCityZone zone = context.getZone(blockThinLocation, blockWorld); SafeCitySubZone subZone = context.getSubZone(blockThinLocation, blockWorld); // if clicked a corner, ignore (resizing) if (zone != null && zone.isCornerLocation(blockThinLocation, blockWorld, false)) { return; } if (subZone != null && subZone.isCornerLocation(blockThinLocation, blockWorld, true)) { return; } // check if player has permission if (!this.checkPermission(event, scPlayer, zone, subZone)) { return; } initCreation(event, scPlayer, zone); }
@EventHandler() public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getItemInHand().getTypeId() == Settings.globals.getInt(Setting.SelectionTool.getString(), 268)) { if (HuntZoneCreation.players.containsKey(event.getPlayer().getName())) { HuntZoneCreation.select(event.getPlayer(), event.getClickedBlock()); event.setCancelled(true); } } }
@Override public void handleClick(PlayerInteractEvent e) { Arena arena = plugin.amanager.getPlayerArena(e.getPlayer().getName()); if (arena != null) { arena .getPlayerHandler() .leavePlayer(e.getPlayer(), Messages.playerlefttoplayer, Messages.playerlefttoothers); e.setCancelled(true); } else { e.getPlayer().sendMessage("You are not in arena"); } }
@EventHandler public void onInteract(PlayerInteractEvent event) { if (isFilly(event.getPlayer())) { if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) { event.setCancelled(true); sendMessage(event.getPlayer(), "Hey! You wanna build? Read that book in your hands!"); if (!event.getPlayer().getInventory().contains(Material.WRITTEN_BOOK)) { event.getPlayer().getInventory().addItem(getFillyHandbook()); } } } }
@EventHandler private void onPlayerInteract(PlayerInteractEvent event) { if (!mIsLoaded) return; if (mLocation.getWorld() != event.getPlayer().getWorld()) return; if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasBlock() && event.getClickedBlock().getLocation().distanceSquared(mLocation) < 1D) { onPlayerActivatePedestal(event.getPlayer()); // event.setUseInteractedBlock(Result.DENY); event.setCancelled(true); } }
@EventHandler public void onInteract(PlayerInteractEvent event) { if (GameManager.INSTANCE.getSession(event.getPlayer()) == null) return; ItemStack item = event.getItem(); if (item == null || (!event.getAction().equals(Action.RIGHT_CLICK_AIR) && !event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) return; if (item.getType().equals(Material.PAPER) && event.getPlayer().getHealth() != 20) { GeneralUtils.subtractItemInHand(event.getPlayer()); GeneralUtils.addHealthByPaper(event.getPlayer()); } if (event.hasBlock() && !Material.WORKBENCH.equals(event.getClickedBlock().getType())) event.setCancelled(true); }
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getClickedBlock().getType() == Material.BOOKSHELF) { if (!event.getPlayer().isSneaking()) { if (plugin.getBookshelfInventory(event.getClickedBlock()) == null) { plugin.createBookshelfInventory(event.getClickedBlock()); } event.getPlayer().openInventory(plugin.getBookshelfInventory(event.getClickedBlock())); event.setCancelled(true); } } } }
/** * Record the right clicking a sign. * * @param event */ @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (this.plugin.getDisabled().contains(event.getPlayer().getName())) return; if (!event.getPlayer().hasPermission("signfix.enable")) return; if (event.getAction() != Action.LEFT_CLICK_BLOCK) return; if (!event.getClickedBlock().getType().equals(Material.SIGN) && !event.getClickedBlock().getType().equals(Material.SIGN_POST) && !event.getClickedBlock().getType().equals(Material.WALL_SIGN)) return; this.plugin .getClicked() .put(event.getPlayer().getName(), (Sign) event.getClickedBlock().getState()); event .getPlayer() .sendMessage(ChatColor.AQUA.toString() + "[SignFix] Selected the sign you've hit."); }
@EventHandler public void playerInteractEvent(PlayerInteractEvent e) { if (!Minegusta.getServer().containsWorld(e.getPlayer().getWorld())) return; DwarfPower rage = DwarfPower.battleCryBoost(e); Altar altar = Altar.altarCheck(e); if (rage.isRightClick() && rage.isPlayer() && rage.isDwarf() && rage.hasAxe()) { rage.applyBattleCryBoost(); } if (altar.isRightClick() && altar.isAltar() && altar.hasDiamondBlocks() && altar.isNotHuman()) { Cure.curePlayer(e.getPlayer()); } }
public void onPlayerInteract(PlayerInteractEvent pie) { if (Action.LEFT_CLICK_BLOCK.equals(pie.getAction()) || (isValidBlock(pie.getClickedBlock()) && Action.RIGHT_CLICK_BLOCK.equals(pie.getAction()))) { Block clicked = pie.getClickedBlock(); Block behind = clicked.getRelative(pie.getBlockFace().getOppositeFace()); SecretDoor door = null; if (Material.WOODEN_DOOR.equals(clicked.getType()) && !SecretDoor.isDoubleDoor(clicked)) { if (this.plugin.isSecretDoor(SecretDoor.getKeyFromBlock(clicked))) { this.plugin.closeDoor(SecretDoor.getKeyFromBlock(clicked)); } else if (!Material.AIR.equals(behind.getType())) { if (SecretDoor.isAdjacentDoor(clicked, pie.getBlockFace())) door = new SecretDoor(clicked, behind, SecretDoor.Direction.DOOR_FIRST); } } else if (Material.WOODEN_DOOR.equals(behind.getType()) && !SecretDoor.isDoubleDoor(behind)) { if (this.plugin.isSecretDoor(SecretDoor.getKeyFromBlock(behind))) { this.plugin.closeDoor(SecretDoor.getKeyFromBlock(behind)); } else if (SecretDoor.isAdjacentDoor(behind, pie.getBlockFace().getOppositeFace())) door = new SecretDoor(behind, clicked, SecretDoor.Direction.BLOCK_FIRST); } if (!(door == null)) { plugin.addDoor(door).open(); pie.getPlayer().sendMessage(ChatColor.RED + "Don't forget to close the door!"); } } }