@EventHandler public void onBlockPlace(PlayerInteractEvent event) { if (getArena().equals(getName())) { Player player = event.getPlayer(); if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (player.getItemInHand().getType() == Material.FIREWORK) { player.getInventory().removeItem(new ItemStack(Material.FIREWORK, 1)); player.setVelocity(new Vector(0, 1, 0)); } } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); Block block = event.getClickedBlock(); if (player.getItemInHand().getType() == Material.STICK) { select(player, event); } /*if(player.getItemInHand().getType() == Material.STICK && player.getItemInHand().hasItemMeta()){ if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.SelectionTool)){ select(player, event); }else if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.InfoTool)){ info(player, block, event); } }*/ if (block == null) { return; } if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK) { pressure(player, block, event); return; } if (event.isCancelled()) { return; } if (player.getItemInHand().getType() == Material.ARMOR_STAND) { armorStand(player, block, event); } interact(player, block, event); }
@EventHandler public void onBlockInteractEvent(PlayerInteractEvent event) { if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR)) || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) { return; } if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) { return; } } Player player = event.getPlayer(); if (plugin.manager.isPlayerInGame(player)) { Game game = plugin.manager.getGame(player); if (!(game.mode == ArenaStatus.INGAME)) { return; } if (game.getPlayersGun(player) != null) { GunManager gunManager = game.getPlayersGun(player); if (gunManager.isGun()) { Gun gun = gunManager.getGun(player.getInventory().getHeldItemSlot()); if (gun.isReloading()) { player.getLocation().getWorld().playSound(player.getLocation(), Sound.CLICK, 1, 1); return; } gun.wasShot(); } } } }
@EventHandler public void onInteract(PlayerInteractEvent pie) { if (pie.getAction().equals(Action.RIGHT_CLICK_BLOCK) || pie.getAction().equals(Action.RIGHT_CLICK_AIR)) { Player player = pie.getPlayer(); World world = player.getWorld(); if (player.getInventory().getItemInHand() != null) { ItemStack item = player.getInventory().getItemInHand(); if (item.getType().equals(Material.DOUBLE_PLANT)) { pie.setCancelled(true); Item bomb = world.dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_BLOCK)); bomb.setPickupDelay(Integer.MAX_VALUE); bomb.setVelocity(player.getLocation().getDirection().multiply(0.5)); double radius = 1.5; for (double i = 0; i <= 20D; i += 0.1) { Item coin = world.dropItem(bomb.getLocation(), new ItemStack(Material.DOUBLE_PLANT)); double x = Math.sin(radius * i); double z = Math.cos(radius * i); Bukkit.getScheduler() .scheduleSyncDelayedTask( Factions.instance, new Runnable() { public void run() {} }, 1); } } } } }
@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"); } } }
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!"); } } }
@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.NORMAL) public void onRightHandPlayerInteact(PlayerInteractEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); if (player != null && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) { Location loc = player.getLocation(); // If block is not null use block location, if null use player loc final Block block = event.getClickedBlock(); if (block != null) loc = block.getLocation(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (player.getItemInHand().getType() == Material.MONSTER_EGG) { if (!(plugin.canBuildOnLocation(player, loc))) event.setCancelled(true); } else if (player.getItemInHand().getType() == Material.FIREBALL) { if (!plugin.canBuildOnLocation(player, loc)) event.setCancelled(true); } } plugin.debug("Evento :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (player.getItemInHand().getType() == plugin.getWorldEditSettings().getWandMaterial()) { PlayerSettings settings = plugin.getPlayerSettings(player); if (event.getAction() == Action.LEFT_CLICK_BLOCK) { settings.setFirstPosition(event.getClickedBlock().getLocation()); if (settings.getSelection() == null) { player.sendMessage("First position is set!"); } else { player.sendMessage( "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)"); } event.setCancelled(true); } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { settings.setSecondPosition(event.getClickedBlock().getLocation()); if (settings.getSelection() == null) { player.sendMessage("Second position is set!"); } else { player.sendMessage( "Second position is set!(" + settings.getSelection().getBlocks().size() + " blocks)"); } event.setCancelled(true); } } }
@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 public void onClick(PlayerInteractEvent e) { if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { if (checkName(e.getPlayer().getItemInHand(), this.name())) { ItemStack i = e.getPlayer().getItemInHand(); List<String> l = i.getItemMeta().getLore(); String s = l.get(0).replace(ChatColor.GRAY + "", ""); if (Zephyrus.spellMap.containsKey(s)) { Spell spell = Zephyrus.spellMap.get(s); Player player = e.getPlayer(); FileConfiguration cfg = PlayerConfigHandler.getConfig(plugin, player); if (!cfg.getStringList("learned").contains(spell.name())) { PlayerLearnSpellEvent event = new PlayerLearnSpellEvent(player, spell); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { List<String> learned = PlayerConfigHandler.getConfig(plugin, player).getStringList("learned"); learned.add(spell.name()); cfg.set("learned", learned); e.getPlayer() .sendMessage("You have successfully learned " + ChatColor.GOLD + spell.name()); e.getPlayer().setItemInHand(null); PlayerConfigHandler.saveConfig(plugin, player, cfg); } } else { e.getPlayer().sendMessage("You already know that spell!"); return; } } else { e.getPlayer().sendMessage("Spell not found..."); } } } }
@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 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); } }
@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); } }
@Override public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (event.useItemInHand() == Result.DENY) return; Hero hero = plugin.getHeroManager().getHero(player); if (hero.hasEffectType(EffectType.DISARM)) Util.disarmCheck(hero, plugin); if (!hero.canEquipItem(player.getInventory().getHeldItemSlot())) { event.setCancelled(true); Util.syncInventory(player, plugin); return; } // Remove effects dependant on non-interaction if (hero.hasEffect("Invisible")) { hero.removeEffect(hero.getEffect("Invisible")); } Block clickedBlock = event.getClickedBlock(); if (clickedBlock != null) { switch (clickedBlock.getType()) { case DISPENSER: case BED: case FURNACE: case BURNING_FURNACE: case WOOD_DOOR: case LEVER: case IRON_DOOR: case JUKEBOX: case DIODE_BLOCK_OFF: case DIODE_BLOCK_ON: case CHEST: case LOCKED_CHEST: case TRAP_DOOR: hero.cancelDelayedSkill(); return; } } if (player.getItemInHand() != null) { Material material = player.getItemInHand().getType(); if (hero.hasBind(material)) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { String[] args = hero.getBind(material); plugin.onCommand(player, null, "skill", args); } else { hero.cancelDelayedSkill(); } } else { hero.cancelDelayedSkill(); } } }
public void select(Player player, PlayerInteractEvent event) { User user = UManager.getUser(player.getUniqueId()); if (event.getAction() == Action.LEFT_CLICK_BLOCK) { player.sendMessage("F"); SelectionManager.SelectFirstPosition(user, event.getClickedBlock().getLocation()); } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { player.sendMessage("S"); SelectionManager.SelectSecondPosition(user, event.getClickedBlock().getLocation()); } event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent event) { SFPlayer player = getPlayer(event.getPlayer()); if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) if (player.canFly()) player.fly(); if (event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK)) player.setHover(); if (player.self().getItemInHand().getType() != plugin.flyTool) player.hover = false; }
public void onPlayerInteract(PlayerInteractEvent event) { Block b = event.getClickedBlock(); Player p = event.getPlayer(); Action a = event.getAction(); // Handle field building tool operations if (p.getItemInHand().getTypeId() == 276) { Builder fb = plugin.getBattlefieldManager().getBuilder(p); if (fb != null) { if (fb.getTool() != null) { Tool tool = fb.getTool(); switch (a) { case RIGHT_CLICK_BLOCK: tool.rightClick(b); break; case LEFT_CLICK_BLOCK: tool.leftClick(b); break; case RIGHT_CLICK_AIR: tool.rightClick(); break; case LEFT_CLICK_AIR: tool.leftClick(); break; default: break; } } } } TeamMember m = plugin.getBattlefieldManager().getPlayer(p); if (m != null) { Battlefield field = m.getTeam().getField(); // Handle sign clicks if (b != null) { if (b.getState() instanceof Sign) { Sign sign = (Sign) b.getState(); String line = sign.getLine(0); if (line.equals("[Options]")) { BattlefieldSign bs = field.getSign(b); if (bs != null) { if (field.isActive()) Format.sendMessage(m, "You cannot change settings during a game."); else if (a == Action.LEFT_CLICK_BLOCK) bs.executeOption(m); else if (a == Action.RIGHT_CLICK_BLOCK) bs.cycleOption(m); } } } } if (field.isActive()) field.getGametype().getListener().onClick(m, event.getClickedBlock(), event.getAction()); } }
@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 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 onPlayerMonkeyBomb(PlayerInteractEvent event) { if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR)) || !(event.getAction().equals(Action.RIGHT_CLICK_AIR))) { return; } if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) { return; } } final Player player = event.getPlayer(); if (plugin.manager.isPlayerInGame(player)) { Game game = plugin.manager.getGame(player); if (!(game.mode == ArenaStatus.INGAME)) { return; } if (player.getItemInHand().getType().equals(Material.MAGMA_CREAM)) { player.getInventory().removeItem(new ItemStack(Material.MAGMA_CREAM, 1)); final Item item = player .getWorld() .dropItemNaturally(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM)); // Location Iloc = item.getLocation(); item.setVelocity(player.getLocation().getDirection().multiply(1)); item.setPickupDelay(1000); /*for(Entity e: game.spawnManager.mobs) { }*/ Bukkit.getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { @Override public void run() { Location loc = item.getLocation(); player .getWorld() .createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false); item.remove(); } }, 140); } } }
@EventHandler public void onPlayerAction(PlayerInteractEvent e) { Player player = e.getPlayer(); if ((e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK) && !e.isCancelled())) { ItemStack item = player.getItemInHand(); if (item.getType() == Material.BOW || item.getType() == Material.SNOW_BALL || item.getType() == Material.EGG || item.getType() == Material.POTION) return; RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return; if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return; if (rItem.getHasPermission() == true && player.hasPermission(rItem.getPermission()) == false) { e.setCancelled(true); player.sendMessage( ChatColor.RED + String.format( Locale.get("message.error.permission", Locale.getPlayerLocale(player)))); } rItem.rightClick(player); if (player.getItemInHand().getTypeId() != 0) { RPGItem.updateItem(item, Locale.getPlayerLocale(player)); } else player.setItemInHand(null); player.updateInventory(); } else if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { ItemStack item = player.getItemInHand(); if (item.getType() == Material.BOW || item.getType() == Material.SNOW_BALL || item.getType() == Material.EGG || item.getType() == Material.POTION) return; RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return; if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return; if (rItem.getHasPermission() == true && player.hasPermission(rItem.getPermission()) == false) { e.setCancelled(true); player.sendMessage( ChatColor.RED + String.format( Locale.get("message.error.permission", Locale.getPlayerLocale(player)))); } rItem.leftClick(player); RPGItem.updateItem(item, Locale.getPlayerLocale(player)); } }
@EventHandler public void onClick2(PlayerInteractEvent e) { Player p = e.getPlayer(); ItemStack item = p.getItemInHand(); if (adminMode.contains(p.getName())) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) { if (item.getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Nearest Player")) { p.performCommand("near"); } } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteract(PlayerInteractEvent e) { SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer()); Block block = e.getClickedBlock(); if (player == null) return; if (block == null) return; if (!player.isActive()) return; if (e.getAction() != Action.LEFT_CLICK_BLOCK) return; Game game = player.getGame(); if (!game.canSpleef(player, block.getLocation())) return; if (game.getFlag(FlagType.BOWSPLEEF) || game.getFlag(FlagType.SPLEGG)) return; if (game.getFlag(FlagType.BLOCKBREAKEFFECT)) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); } block.setType(Material.AIR); player.addBrokenBlock(block); }
@EventHandler(priority = EventPriority.NORMAL) public void togglePlayerStacker(PlayerInteractEvent event) { // Do nothing if player is not right clicking. Action action = event.getAction(); if (action != RIGHT_CLICK_AIR && action != RIGHT_CLICK_BLOCK) return; // Do nothing if player does not have permission. Player player = event.getPlayer(); if (!Perm.PLAYERSTACKER.has(player)) return; // Do nothing if player is not clicking the player hider item. if (!player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemDisabled()) && !player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled())) return; // Do nothing if user is null. User user = plugin.getUser(player.getUniqueId()); if (user == null) return; // Toggle users stacking option. user.setStacking(!user.isStacking()); // Update players inventory with the newer player hider item. if (plugin.getSettings().getPlayerStackerSlot() >= 0) { ItemStack reverse = player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled()) ? plugin.getSettings().getPlayerStackerItemDisabled() : plugin.getSettings().getPlayerStackerItemEnabled(); player.getInventory().setItem(plugin.getSettings().getPlayerStackerSlot(), reverse); player.updateInventory(); } // Play a clicking sound. player.playSound(player.getLocation(), Sound.CLICK, 2.0F, 1.0F); }
// Hits a netherrack block public void onPlayerInteract(PlayerInteractEvent event) { // Do not run if cancelled if (event.isCancelled()) { return; } // Only run if netherrack ignition is enabled if (igniteNetherrack) { // Check to see if player clicked a netherrack block if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (event.getClickedBlock().getType() == Material.NETHERRACK) { // Ignite this block if Firetouch enabled Player player = event.getPlayer(); PotionEntry buff = getPlugin().BuffList.get(player); if (buff != null) { if (buff.HasBuff.get(Name) != null && buff.HasBuff.get(Name)) { // Ignite block BlockIgniteEvent ignite = new BlockIgniteEvent( event.getClickedBlock(), IgniteCause.FLINT_AND_STEEL, player); getPlugin().getServer().getPluginManager().callEvent(ignite); if (!ignite.isCancelled()) { Block above = event.getClickedBlock().getRelative(0, 1, 0); if (above.isEmpty()) { above.setType(Material.FIRE); } } } } } } } }
@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()); } } } }
public void onPlayerInteract(PlayerInteractEvent ev) { Player player = ev.getPlayer(); World world = player.getWorld(); Location playerLoc = player.getLocation(); ItemStack arrow = new ItemStack(Material.ARROW, 5); if (ev.getAction() == Action.LEFT_CLICK_AIR) { if (player.getItemInHand().getType() == Material.BOOK) { if (player.hasPermission("s.shotgun") || player.isOp()) { player.shootArrow(); player.shootArrow(); player.shootArrow(); player.shootArrow(); player.shootArrow(); world.playEffect(playerLoc, Effect.BOW_FIRE, 50); world.createExplosion(playerLoc, -1); world.createExplosion(playerLoc, -1); world.playEffect(playerLoc, Effect.SMOKE, 105); player.getInventory().removeItem(arrow); } } } }
@EventHandler public void onPlayerInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); if (p.getItemInHand().getType() == Material.EYE_OF_ENDER && p.getItemInHand().getDurability() == 1) { Action a = e.getAction(); if ((a == Action.RIGHT_CLICK_AIR) || (a == Action.RIGHT_CLICK_BLOCK)) { try { if (p.getInventory().getHelmet().getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getChestplate() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getLeggings() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { if (p.getInventory() .getBoots() .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 7) { p.launchProjectile(EnderPearl.class); } } } } else if (p.getInventory().getChestplate() != null) { if (p.getInventory().getChestplate().hasItemMeta()) { if (p.getInventory().getChestplate().getItemMeta().hasDisplayName()) { if (p.getInventory() .getChestplate() .getItemMeta() .getDisplayName() .equalsIgnoreCase( ChatColor.BLUE + "" + ChatColor.BOLD + "Uber" + ChatColor.GOLD + "" + ChatColor.BOLD + "Chestplate")) { if (p.getInventory() .getChestplate() .getItemMeta() .getLore() .contains(ChatColor.GRAY + "Ender Fake")) { p.launchProjectile(EnderPearl.class); } } } } } } catch (Exception x) { } e.setCancelled(true); } } }
@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); } }