public static Block getTargetEarthBlock(final Player player, final int range) { return player.getTargetBlock(getTransparentMaterialSet(), range); }
@EventHandler @SuppressWarnings("deprecation") public void onPlayerInteractBlock(PlayerInteractEvent event) { Player player = event.getPlayer(); float explosionPower = this.getConfig.getFloat("power"); //this is what we changed if(player.getItemInHand().getType() == Material.DIAMOND_SWORD) { player.getWorld().strikeLightning(player.getTargetBlock(null, 50).getLocation()); player.getWorld().createExplosion(player.getTargetBlock(null, 50).getLocation(), explosionPower); } }
@EventHandler @SuppressWarnings("deprecation") public void onPlayerInteractBlock(PlayerInteractEvent event){ Player player = event.getPlayer(); if (player.getItemInHand().getType().equals(Material.DIAMOND_SWORD)){ float explosionPower = this.getConfig.getFloat("power"); player.getWorld().strikeLightning(player.getTargetBlock(null, 50).getLocation()); player.getWorld().createExplosion(player.getTargetBlock(null, 50).getLocation(), explosionPower); } }
public void setFishingTarget() { getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); }
public boolean exploitPrevention(BoundingBox boundingBox) { Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); if (!targetBlock.isLiquid()) { return false; } long currentTime = System.currentTimeMillis(); boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10)); if(hasFished) fishingTimestamp = currentTime; boolean sameTarget = (lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(boundingBox)); lastFishingBoundingBox = boundingBox; return hasFished || sameTarget; }
public void cast(Player caster) { Location loc = caster.getTargetBlock(null, 512).getLocation(); for (int c = 0; c < 2; c++) { for (int b = 0; b < 2; b++) { for (int a = 0; a < 1; a++) { caster.sendMessage("" + loc); caster.getWorld().getBlockAt(loc.clone().add(a, b, c)).setTypeId(79); } } } }
public static Location getTargetLoc(Player player, int maxDist, double addY) { try { Location target = player.getTargetBlock((Set<Material>) null, maxDist).getLocation(); target.setY(target.getY() + addY); return target; } catch (Exception ignored) { return null; } }
@Override public PowerResult<Void> fire(Player player, ItemStack stack) { Block targetBlock = player.getTargetBlock(null, distance); if (targetBlock == null) return PowerResult.noop(); return fire(player, stack, targetBlock.getLocation()); }
public void cast(Player caster){ Location loc = caster.getTargetBlock(null, 512).getLocation(); for (int c = -3; c < 3; c++) for (int b = -1; b < 5; b++) for (int a = -3; a < 3; a++) { Block ice = caster.getWorld().getBlockAt(loc.add(a, b, c)); ice.setTypeId(79); loc = loc.subtract(a, b, c); } }
public Location getSenderTargetBlockLocation() { if (sender == null) return location; if (sender instanceof Player) location = ((Player) sender).getTargetBlock((java.util.Set<org.bukkit.Material>) null, 50).getLocation(); else if (sender instanceof BlockCommandSender) location = ((BlockCommandSender) sender).getBlock().getLocation(); return location; }
public static Location getTargetedLocation(final Player player, final double originselectrange, final Material... nonOpaque2) { final Location origin = player.getEyeLocation(); final Vector direction = origin.getDirection(); HashSet<Material> trans = new HashSet<Material>(); trans.add(Material.AIR); if (nonOpaque2 == null) { trans = null; } else { for (final Material material : nonOpaque2) { trans.add(material); } } final Block block = player.getTargetBlock(trans, (int) originselectrange + 1); double distance = originselectrange; if (block.getWorld().equals(origin.getWorld())) { distance = block.getLocation().distance(origin) - 1.5; } final Location location = origin.add(direction.multiply(distance)); return location; }
public static void form(final Player player) { if (!hasAbility(player, LavaSurgeWall.class)) { new LavaSurgeWave(player); return; } else if (isLavabendable(player, player.getTargetBlock((HashSet<Material>) null, SURGE_WAVE_RANGE))) { new LavaSurgeWave(player); return; } moveLava(player); }
@Override public void run() { plugin.getTrackerKeeper().getInvisibleDoors().forEach((key, value) -> { Player p = plugin.getServer().getPlayer(key); if (p != null && p.isOnline() && plugin.getTrackerKeeper().getSpectacleWearers().contains(key)) { String b = p.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 50).getRelative(BlockFace.UP).toString(); if (b.equals(value.toString())) { ResultSetTardisID rs = new ResultSetTardisID(plugin); if (rs.fromUUID(key.toString())) { HashMap<String, Object> wherec = new HashMap<>(); wherec.put("tardis_id", rs.getTardis_id()); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherec); if (rsc.resultSet()) { p.sendBlockChange(value.getLocation(), lower.get(rsc.getDirection())); p.sendBlockChange(value.getRelative(BlockFace.UP).getLocation(), upper); } } } } }); }
void handleInteract(final Player player, Cancellable cancellable, final int action/* 0 = interact (right-click), 1 = attack (left-click) */) { Block targetBlock = player.getTargetBlock((Set<Material>) null, 16); if (targetBlock != null && targetBlock.getType() != Material.AIR) { Set<AnimatedFrame> frames = plugin.frameManager.getFramesInWorld(player.getWorld().getName()); frames.removeIf(f -> !f.isClickable()); final CursorPosition.CursorMapQueryResult queryResult = CursorPosition.findMenuByCursor(player, frames); if (queryResult != null && queryResult.isFound()) { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { queryResult.getClickable().handleClick(player, queryResult.getPosition(), action); } }); // cancellable.setCancelled(true); } } }
@EventHandler public void onPlayerInteractBlockTeleport(PlayerInteractEvent event) { Player player = event.getPlayer(); //Null check isn't necessary anymore, an empty item will have Material.AIR and getTargetBlock() now also works if no target block is found if (player.getItemInHand().getType() == Material.BONE) { Location playerLoc = player.getLocation(); //Get the player's location Location target = player.getTargetBlock((Set) null, 200).getLocation().clone().add(0, 1, 0); //Get the block location + 1 y target.setYaw(playerLoc.getYaw()); //Set the yaw of the target location to the player's yaw target.setPitch(playerLoc.getPitch()); //Set the pitch of the target location to the player's pitch player.teleport(target); //Teleport player player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 10, 1); //Play sound } }
@Override public boolean check(String playerID) throws QuestRuntimeException { Player p = PlayerConverter.getPlayer(playerID); Block lookingAt = p.getTargetBlock(null, 6); if (loc != null) { Location location = loc.getLocation(playerID); Location to = lookingAt.getLocation(); if (location.getBlockX() != to.getBlockX() || location.getBlockY() != to.getBlockY() || location.getBlockZ() != to.getBlockZ()) return false; } if (type != null) { if (type != lookingAt.getType()) return false; } return true; }
@EventHandler public void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); if (sessions.getSession(UserSession.class, player).hasThor()) { if (!config.thorItems.contains(player.getItemInHand().getTypeId())) { return; } if (event.getAction() == Action.LEFT_CLICK_AIR) { Block block = player.getTargetBlock((Set<Material>) null, 300); if (block != null) { player.getWorld().strikeLightning(block.getLocation()); } } else if (event.getAction() == Action.LEFT_CLICK_BLOCK) { Block block = event.getClickedBlock(); player.getWorld().strikeLightning(block.getLocation()); } } }
public boolean set(CommandSender sender) { if (!(sender instanceof Player)) { TARDISMessage.send(sender, "CMD_ONLY_PLAYER"); return true; } Player player = (Player) sender; Block b = player.getTargetBlock(plugin.getGeneralKeeper().getTransparent(), 10); Material chest = b.getType(); if (!chest.equals(Material.CHEST)) { TARDISMessage.send(sender, "UPDATE_CONDENSER"); return true; } String loc = b.getLocation().toString(); // update the artron config plugin.getArtronConfig().set("condenser", loc); try { plugin.getArtronConfig().save(new File(plugin.getDataFolder(), "artron.yml")); } catch (IOException io) { plugin.debug("Could not save artron.yml, " + io); } TARDISMessage.send(sender, "CONFIG_UPDATED"); return true; } }
/** * Detonate TNT for Blast Mining */ public void remoteDetonation() { Player player = getPlayer(); Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); //Blast mining cooldown check needs to be first so the player can be messaged if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true)) { return; } TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); //SkillUtils.sendSkillMessage(player, SuperAbilityType.BLAST_MINING.getAbilityPlayer(player)); NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); //player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata()); tnt.setFuseTicks(0); targetBlock.setType(Material.AIR); mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis()); mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false); new AbilityCooldownTask(mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); }
public void moveWater() { if (this.sourceBlock != null) { this.targetDestination = this.player.getTargetBlock(getTransparentMaterialSet(), (int) this.range).getLocation(); if (this.targetDestination.distanceSquared(this.location) <= 1) { this.progressing = false; this.targetDestination = null; } else { this.bPlayer.addCooldown("SurgeWall", this.cooldown); this.progressing = true; this.settingUp = true; this.firstDestination = this.getToEyeLevel(); this.firstDirection = this.getDirection(this.sourceBlock.getLocation(), this.firstDestination); this.targetDirection = this.getDirection(this.firstDestination, this.targetDestination); if (isPlant(this.sourceBlock) || isSnow(this.sourceBlock)) { new PlantRegrowth(this.player, this.sourceBlock); this.sourceBlock.setType(Material.AIR); } this.addWater(this.sourceBlock); } } }