@EventHandler public void onInteract(PlayerInteractEvent e) { if ((e.getAction() == Action.RIGHT_CLICK_BLOCK) && (e.getClickedBlock().getType() == Material.STONE_BUTTON)) { Location block = e.getClickedBlock().getLocation().add(1.0D, 0.0D, 0.0D); Location block1 = e.getClickedBlock().getLocation().add(-1.0D, 0.0D, 0.0D); Location block2 = e.getClickedBlock().getLocation().add(0.0D, 0.0D, 1.0D); Location block3 = e.getClickedBlock().getLocation().add(0.0D, 0.0D, -1.0D); if ((block.getBlock().getType() == Material.JUKEBOX) || (block1.getBlock().getType() == Material.JUKEBOX) || (block2.getBlock().getType() == Material.JUKEBOX) || (block3.getBlock().getType() == Material.JUKEBOX)) { for (Player p : getPlayersInRadius(e.getClickedBlock().getLocation(), 5)) { Random rand = new Random(); double x = rand.nextDouble() * 5000.0D - 2500.0D; double z = rand.nextDouble() * 5000.0D - 2500.0D; Location loc = new Location(e.getPlayer().getWorld(), x, e.getPlayer().getWorld().getHighestBlockYAt((int)x, (int)z), z); e.getPlayer().teleport(loc); Location ploc = new Location(e.getPlayer().getWorld(), e.getPlayer().getLocation().getX(), e.getPlayer().getLocation().getY(), e.getPlayer().getLocation().getZ()); ploc.setY(e.getPlayer().getLocation().getY() + 5.0D); e.getPlayer().teleport(ploc); p.teleport(e.getPlayer().getLocation()); p.sendMessage(ChatColor.RED + "Przeteleportowano w losowe koordynaty! " + ChatColor.GRAY + "(x: " + (int)x + " | z: " + (int)z + ")"); } } }